LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to separate certain numbers from the whole output?

Solved!
Go to solution

The following was got from the standard output window of the 'calling system exec' vi. My question is how to separate the 'actual read value' numbers (in bold) from the whole output and output them separately.

 

37- Result=OK, line=0x5D,RW,0x21,, #Read VOUT_COMMAND value
   Actual Read Value:0x3000

38- Result=OK, line=0x5D,WW,0x21,0x3000, #Write VOUT_COMMAND to '1.5 V'

39- Result=OK, line=0x5D,WB,0x00,0x01,# write PAGE to 1

40- Result=OK, line=0x5D,RW,0x8B,, #Read READ_VOUT value
   Actual Read Value:0x3002

41- Result=OK, line=0x5D,RW,0x8C,, #Read READ_IOUT value
   Actual Read Value:0xBBB4

42- Result=OK, line=0x5D,RW,0x96,, #Read READ_POUT value
   Actual Read Value:0xC2C7

 

Thank you very much.

0 Kudos
Message 1 of 8
(3,632 Views)

Search the string for "Value:" and take the number after it up to the linefeed character.

0 Kudos
Message 2 of 8
(3,614 Views)

Here is a way to do it with regex. This assumes all values will be hex in the 0x... format.

 

Disclaimer: I am not a regex pro and there could be an easier way to do this, possibly without the while loop.

 

 

 

 

 

Message 3 of 8
(3,610 Views)
Solution
Accepted by topic author ZCY4444

@for(imstuck) wrote:

Here is a way to do it with regex.

Disclaimer: I am not a regex pro and there could be an easier way to do this, possibly without the while loop.


Right on! You're at least 80% of the way there with this solution, but as you mention the regex could be improved a bit to be more robust. But the structure of the code (including the While Loop, autoindexing w/ conditional concat) is spot-on. (Only code structure i would change is not wiring the "multiline (F)?" input on the Match node, but rather, specifying this in the regex itself if necessary -- most of that is preference, not correctness -- and in this case, we don't need multiline since we're shifting the start index)

 

Have a go with this regex: (?<=Actual Read Value:)0x[0-9A-Fa-f]{4}(?=(?:\s|\z))

 

Read it like:

  1. (?<=Actual Read Value:) -- Lookbehind as a zero width assertion, ensuring it's before the match but not part of the match
  2. 0x -- text literal match
  3. [0-9A-Fa-f] -- Look for any one hex character...
  4. {4} - ... and repeat that character exactly four times
  5. (?=(?:\s|\z)) -- and Lookahead, to ensure that hex value is following by either exactly one whitespace character OR the End Of String anchor, without capturing that subgroup as a match
0 Kudos
Message 4 of 8
(3,576 Views)

JackDunaway wrote: 

Have a go with this regex: (?<=Actual Read Value:)0x[0-9A-Fa-f]{4}(?=(?:\s|\z))


Oh fiddlesticks. This is what happens when forum software doesn't correctly construct regexes for smiley replacements 😞

 

Copy this one:

 

(?<=Actual Read Value:)0x[0-9A-Fa-f]{4}(?=(?:\s|\z))
Message 5 of 8
(3,575 Views)

Thanks a lot for the help! It works now

0 Kudos
Message 6 of 8
(3,561 Views)

@ZCY4444 wrote:

Thanks a lot for the help! It works now


right on! for(imstuck) did the heavy lifting here 🙂

0 Kudos
Message 7 of 8
(3,554 Views)

Thank you very much. Smiley Happy 

0 Kudos
Message 8 of 8
(3,550 Views)