08-10-2017 09:27 AM
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!!
Solved! Go to Solution.
08-10-2017 09:51 AM
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
08-10-2017 09:55 AM - edited 08-10-2017 09:56 AM
So this is what I have now. I used the syntax You suggested. But it didn't quite give the answer.
08-10-2017 10:01 AM
I used [0-9]+\.[0-9]+ and I was able to separate the voltage and dBm numerical values
08-10-2017 10:23 AM
08-10-2017 10:28 AM
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.
08-10-2017 10:28 AM
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.
08-10-2017 10:31 AM
Wonderful!! Thank you very Much!!
08-10-2017 10:32 AM - edited 08-10-2017 10:49 AM
@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
EDIT:
oh, I realize you should use the remove file extension vi, which ben showed in Message 5
08-10-2017 11:01 AM
Thank you to you too!