From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-03-2013 02:17 PM - edited 05-03-2013 02:18 PM
Hi,
I need to duplicate functionality of match pattern function with regular expression and scan from string of attached vi.
Basically, I want to split the string when a serial number (SN) along with the "XXX" is found within the string. The working function is with bold font on front panel. Thanks,
frn
05-03-2013 02:27 PM
@frn wrote:
Hi,
I need to duplicate functionality of match pattern function with regular expression and scan from string of attached vi.
Basically, I want to split the string when a serial number (SN) along with the "XXX" is found within the string. The working function is with bold font on front panel. Thanks,
frn
Im not sure I understand. It's working, soooo...?
05-03-2013 02:31 PM
I'm sorry, your question doesn't make sense. Right now your code splits the string on any character that is between X and x. Since the string starts <AX, it splits the string at that X. The "after substring" indicator contains the rest of the string, including the V123.12[ZZ1]. You just can't see it because the string has line wrapping enabled, so that portion gets shoved onto a second line, and the indicator only shows one line.
What are you trying to do here?
05-03-2013 03:07 PM
I need to display "SN XXX" into a separate indicator, using this string as an example: "<AX SN XXX V123.12[ZZ1]"
And I am looking at three different solutions as to select either option: match pattern, regular expression and scan from string.
Thanks,
frn
05-03-2013 03:19 PM
Is it the exact string "SN XXX" or are the Xs in place of numbers or something else?
Do you understand that your "working" solution doesn't actually work, because it simply hides the following text by wrapping it to a new line?
If you're just looking for "SN XXX" then you can use that exact string as the pattern to match. You probably don't want to use [X-x], which matches X, x, or -.
05-03-2013 03:26 PM
Hi Nathand,
Answer to your question:
Is it the exact string "SN XXX" or are the Xs in place of numbers or something else?
The Xs are Xs and I tried your approach ("SN XXX") at it works great! How would you change the other two functions to get the same result: regular expression and scan from string.
Thanks,
frn
05-03-2013 03:39 PM
I tried the same approach in regular expression and works too. How do I change scan from string to duplicate functionality as the other two?
attached VI.
05-03-2013 03:46 PM
@frn wrote:
I tried the same approach in regular expression and works too. How do I change scan from string to duplicate functionality as the other two?
This is still wrong. Why are you putting the brackets [] around the string you want to search for in Match Pattern? That searches for any one of the characters inside it, instead of searching for the entire string, so you're still not extracting the desired string. After running your VI, put the cursor in the After Substring indicator and hold down the right arrow. You'll see what I mean. Or, right-click that indicator and uncheck "Enable Wrapping."
The parentheses around the string for Match Regular Expression are harmless but also not necessary.
Scan from String is not useful for extracting specific characters from a string - why would we need a third function that duplicates the other two? Scan from String is good for getting only the variable parts of a string while ignoring the fixed parts, which is the opposite of what you seem to be trying to do.
05-03-2013 04:08 PM - edited 05-03-2013 04:09 PM
Hi Nathand,
You are right again. After I removed the brackets [] it works correctly. I was trying to see the difference between these 3 functions so as to use the best one for my application.
Basically what I want to do is to extract any text within a string that contains "XXX" and XXX are litterally "Xs".
Two samples of these strings are as follows:
<TTT BYTE0x0000 ZZXXX CECUXXX AAXXX LXXX or <AX SN XXX V123.12[ZZ1]
How would I extract this text:
SN XXX (space between SN and XXX)
ZZXXX
AAXXX
CECUXXX
LXXX
Thanks,
frn
05-03-2013 04:18 PM
You need to be more specific about what you want to match. How many characters do you want to match before the XXX? If there is a space, will it only ever be immediately before the XXX, or do you also want to match "S NXXX"? Will there always be a space before the text that you want to match, or could it also be at the beginning of the string (immediately after the '<')? In the first example string, do you need to match all 4 occurrences, or just the first one? Do you need all 4 occurrences returned as one string, or as an array of strings? When there are multiple occurences, will they occur in a row, or can there be other text in the middle?
Spend some time reading about regular expressions, either in the LabVIEW help or on the web.