cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Match Pattern Syntax help

Solved!
Go to solution

Match Pattern Syntax help

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
(307 Views)

Re: Match Pattern Syntax help

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
(295 Views)

Re: Match Pattern Syntax help

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
(287 Views)

Re: Match Pattern Syntax help

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

0 Kudos
Message 4 of 17
(278 Views)

Re: Match Pattern Syntax help

You can use Search and Replace String.vi instead.

search and replace string.png

 

Ben64

 

--------------------------------------------------
The best way to say thanks is to give kudos!
Message 5 of 17
(261 Views)

Re: Match Pattern Syntax help

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
(252 Views)
Highlighted
Solution
Accepted by topic author Huqs
08-10-2017 08:31 AM

Re: Match Pattern Syntax help

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
(251 Views)

Re: Match Pattern Syntax help

Wonderful!! Thank you very Much!!

0 Kudos
Message 8 of 17
(245 Views)
Solution
Accepted by topic author Huqs
08-10-2017 08:34 AM

Re: Match Pattern Syntax help


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

compiling executables with LabView 2015 professional and occasionally 2017

0 Kudos
Message 9 of 17
(243 Views)

Re: Match Pattern Syntax help

Thank you to you too!

0 Kudos
Message 10 of 17
(223 Views)