03-01-2015 11:38 AM
Bit of background. I'm getting both text (can contain numbers) and data (only numbers) from serial. Since I don't know which I'm receiving and when it starts/ends, I'm making the sender send "textSTART###textSTOP" where "###" is what I want to extract. ### can contain text, numbers, new line, carrige return or whatever.
The same for data: "dataSTART###dataSTOP", where ### contains only numbers.
I think I should use Match Pattern, but I don't know how to make my regular expression.
Any help is appreciated.
Solved! Go to Solution.
03-01-2015 11:46 AM
What is your question exactly?
03-01-2015 11:51 AM
What regular expression should I use with the Match Pattern VI to extract ### from a string like "testSTART###textSTOP" where ### can be anything from letters, numbers, and special characters like newline or carrige return?
03-01-2015 11:55 AM
What determines whether something is part of #### or a part of the other "text" that appears before STOP?
Can you also give a more specific example of what the data might look like?
03-01-2015 12:03 PM
Sorry for being vague. "textSTART" and "textSTOP" is what I plan to mark my begging and end of the string I receive.
Example:
"textSTARTProgram Ready
Threshold: 127
Prescaler: 64
Baudrate: 115200textSTOP"
Other stuff I can receive would be data numbers for which I'll use a different Match Pattern VI. Example:
"dataSTART154613516846135156161dataSTOP"
Although the numbers will be in binary form. I'll figure that out later. 🙂
03-01-2015 12:32 PM
There are many solutions if you only wants to extract the string between your specific delimiters. Here's one solution:
03-01-2015 01:17 PM
03-01-2015 01:27 PM - edited 03-01-2015 01:28 PM
If the string does not contain anything outside these "delimiters" and there are exactly two per string, you could simply use scan strings for tokens. You can also add the "dataSTART/STOP" delimiters to the array to make it universal and look at the beginning of the raw string to determine if you are dealing with a "data" or "text" message.
Here's a quick draft.
03-01-2015 02:00 PM
@Surreal wrote:
......
I think I should use Match Pattern, but I don't know how to make my regular expression.
......
Here is another solution based on regular expression match
03-01-2015 02:22 PM