LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match Pattern Syntax help

Solved!
Go to solution

Hello everyone, 

I have been using Match pattern to break down a file name. This is just a quick question, can anyone show me what Syntax combination do I use to break this line:

_Ring-0.10V_MZI1-0.00V_MZI2-0.00V_ 0.00dBm.csv

into separate substrings such as this:

Ring  0.10V  MZI1  0.00V  MZI2  0.00V  0.00dBM

 

I don't really care about the last part  .csv

If anyone can help that would be great! Thank you!!

0 Kudos
Message 1 of 17
(3,508 Views)

Anything in brackets creates a class of characters, any of which will return a result.  In your case [-_] should work.  You are going to have to feed that whole string into a loop and do the match several times to get all of the parts separated.

 

-DR2

Message 2 of 17
(3,496 Views)

So this is what I have now. I used the syntax You suggested. But it didn't quite give the answer.

Match Pattern.png

0 Kudos
Message 3 of 17
(3,488 Views)

I used  [0-9]+\.[0-9]+   and I was able to separate the voltage and dBm numerical values

0 Kudos
Message 4 of 17
(3,479 Views)

You can use Search and Replace String.vi instead.

search and replace string.png

 

Ben64

 

Message 5 of 17
(3,462 Views)

Do you think you can give the actual VI or make 2015 compatible? I wasn't able to open it in my 2015 Labview Version.

0 Kudos
Message 6 of 17
(3,453 Views)
Solution
Accepted by topic author Huqs

Try this in your "string 3"

[a-zA-Z0-9\.]+

Gave me:

 

Ring

0.10V

MZI1

0.00V

MZI2

0.00V

0.00dBm.csv

 

You can strip the file name if needed as Ben said. Also, if you then need the numbers from the voltages etc, use the scan from string function with %f as the format string.

Ian
LabVIEW since 2012
Message 7 of 17
(3,452 Views)

Wonderful!! Thank you very Much!!

0 Kudos
Message 8 of 17
(3,446 Views)
Solution
Accepted by topic author Huqs

@Huqs wrote:

Hello everyone, 

I have been using Match pattern to break down a file name. This is just a quick question, can anyone show me what Syntax combination do I use to break this line:

_Ring-0.10V_MZI1-0.00V_MZI2-0.00V_ 0.00dBm.csv

into separate substrings such as this:

Ring  0.10V  MZI1  0.00V  MZI2  0.00V  0.00dBM

 

I don't really care about the last part  .csv

If anyone can help that would be great! Thank you!!


for your task, you could use this build-in vi directly, to split up the input string according to "-" and "_"

http://zone.ni.com/reference/en-XX/help/371361H-01/glang/scan_string_for_tokens

2017-08-10_172950_token.png

 

 

EDIT:

oh, I realize you should use the remove file extension vi, which ben showed in Message 5

0 Kudos
Message 9 of 17
(3,444 Views)

Thank you to you too!

0 Kudos
Message 10 of 17
(3,424 Views)