Tony Tony - 5 months ago 9
Vb.net Question

vb.net regex - capture text between comms

I am trying to extract the first three columns from these two lines of text.

A,Frequency,1.005 kHz,1.005 kHz,1.005 kHz,1.005 kHz,94.75 mHz,20,WholeTrace,
A,True RMS,1.404 V,1.403 V,1.404 V,1.403 V,232.6 æV,20,WholeTrace,


So what I would like displayed (extracted) form the above string is:

1.005 kHz
1.404 V


I found this post Regex exclusive capture between strings (VB.NET)

Which is seemingly doing something very similar, so I tried to modify that regex, however I am failing dismally (not least of all because I am really struggling to understand regular expressions!).

For mine, I tried

cy,\s+(\d+)\s+Hz\s+


But that doesn't work.

Could someone kindly help please?

This is in vb.net (VS 2013)

Answer

Using a Split function:

Dim value As String = Split("A,Frequency,1.005 kHz,1.005 kHz,1.005 kHz,1.005 kHz,94.75 mHz,20,WholeTrace,", ",")(2)