LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match Pattern 'xx' but not 'xxx'

Solved!
Go to solution

Hi dear community!

 

Once again, I need your help: I want to read the substring of an ascii string after a specific marker, here 'xx'. Now a problem arises when the string contains the sequence 'xxx': In these cases the start of the substring is wrong, as the substring starts with 'x'.

 

How do I search for occurences of 'xx', but exclude 'xxx'?

 

 

Alternatively: How do I search for 'xxx' or 'xx', so that the substring definitly starts with the desired byte?

 

 

Sincerely,

Friedrich G. Froebel

0 Kudos
Message 1 of 8
(5,026 Views)

I was thinking of a regular expression (string function) like  (xx)[^x]  , matching xx not followed by x

 

You can do neat things with regexp, google it!

0 Kudos
Message 2 of 8
(5,015 Views)

Hi Friedrich,

 

you could eliminate all found occurances when their offset is just different by one from the previous found substring...

 

But more important: you should use some better marker bytes to prevent them from being the same as your actual data bytes! (For more background on this question read Friedrichs previous thread here...)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(5,010 Views)

Hey Xilinx!

 

Thanks for your reply. I already tried something like (xx)[^x], but neither is working 😕

 

@Gerd: Assuming that our next substring does not have 'xxx' in it too! I need something more bullet proof 😄

What characters are you proposing? I chose these characters as they i) are visible and ii) represent a high value, meaning they are less frequent, if we assume mostly low values.

0 Kudos
Message 4 of 8
(4,952 Views)
Hey Frieder,

How about direct comparison of xx with xxx and xx. did u check that??
Thanks
uday
0 Kudos
Message 5 of 8
(4,945 Views)

After reading the other thread linked by GerdW, it seems that all you need to do is two things:

 

1. Send the 10 bit data as two bytes formatted like this: 000b9b8b7b6b5 and 000b4b3b2b1.

 

2. Select as the marker bytes "xx" characters formatted like this: 111xxxxx and 111xxxxx. 

 

This format arrangement cannot ever have three "x" characters in a row.

 

Many other arrangements are possible, but this shows the concept of making the data and the markers mutually unique.

 

Lynn

0 Kudos
Message 6 of 8
(4,919 Views)

@udka: I am on to that. And thanks for the advice about the kudos Smiley Wink

 

@John: I did not get your post: Under 1. you write an 8-byte and a 7-byte string. Under 2. you write 8 bytes twice (I guess)?

0 Kudos
Message 7 of 8
(4,887 Views)
Solution
Accepted by topic author Frieder713

Friedrich,

 

I cannot count any better than I can type!

 

The second byte in 1 should have been 000b4b3b2b1b0.

 

The character or characters used for the marker could be repeated as you do with your "xx" or they could be two different characters starting with 1s. If you can define a unique character, and it seems to me that this does that, you could use just one character as the marker.

 

Let the marker character "x" = 11111010 (hex FA) for example. Let the first 10-bit data value be 25 (decimal) = 00000 11001. The second data point 139 => 00100 01011 and the third datapoint 944 => 11101 10000. Then the string could be 11111010 00000000 00011001 00000100 00001011 00011101 00010000.  The marker character is shown in bold. The data bits are underlined and the byte containing the most significant bits is in italics. I might change the prefix bits on the most significant bytes to 001 to provide additional confidence that the data is being decoded properly.

 

Lynn

 

Message 8 of 8
(4,870 Views)