11-07-2017 04:23 AM
Hello all, i apologize if this has been asked before.
I have come up with a simple VI to grab specific characters from a string.
However I want to go 1 step further, which is to ensure that the characters are integers and not other characters.
I have no luck so far to get my VI to perform that extra task, so is there anyone who can advise me?
I have attached the current VI that I am using now.
Thank you.
JonKang
11-07-2017 04:41 AM
|testres=[0-9]+ Verify FOE_Y in value,
11-07-2017 06:19 PM
The character that I am looking for is after the ","
Example: this is the whole string that I receive
BCNF|id=xxxxxxxxx|testres=8016 Verify FOE_Y in value,-4|testres=8017 Verify FOE_X in value,-2|
The 2 values I need to grab and verify are the '-4' and '-2'
So far I am able to get the numbers but I am stuck with the conversion between string & integer.
Thank you
11-08-2017 01:03 AM
Hi Kang,
The 2 values I need to grab and verify are the '-4' and '-2'
Those values are missing in your example…
So far I am able to get the numbers but I am stuck with the conversion between string & integer.
Where are you stuck?
Your VI already contains a conversion from string to numeric data, but you aren't able to use this function???
I would search for "Verify" in your input string, then parse the next string to determine either FOE_X/FOE_Y. With the remaining string I would use ScanForString with "in value,%d"…
11-08-2017 03:22 AM
@KangJonathan wrote:
The character that I am looking for is after the ","
Example: this is the whole string that I receive
BCNF|id=xxxxxxxxx|testres=8016 Verify FOE_Y in value,-4|testres=8017 Verify FOE_X in value,-2|
The 2 values I need to grab and verify are the '-4' and '-2'
So far I am able to get the numbers but I am stuck with the conversion between string & integer.
Well, you didn't say you want to grab them. You only mentioned search and check...
Use Decimal String To Number to convert the string to integer.
But why not use a Scan From String? It's much cleaner and safer then two match patterns. The format string would be:
BCNF|id=%[^|]testres=%d Verify FOE_Y in value,%d|testres=%d Verify FOE_X in value,%d|
That would give you a string, and 4 integers (extract the bottom to 5 outputs):
BCFN|id= matches the literal string
%[^|] matches anything but |
testres= matches the literal string
%d matches any integer
Verify FOE_Y in value, matches the literal string
%d matches any integer
|testres= matches the literal string
%d matches any integer
Verify FOE_X in value, matches the literal string
%d matches any integer
| matches the literal string