LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

regular expression problem with brackets

Solved!
Go to solution

Hello,

 

I have a Zebra printer string that contains tokens I want to search for.

 

^BY2,3,55^FT50,219^BCN,,Y,N..^FD>:[[Serial Number 1]]^FS
^BY2,3,55^FT525,221^BCN,,Y,N..^FD>:[[Serial Number 2]]^FS
^FT170,192^XG000.GRF,1,1^FS
^FT220,430^A0N,27,27^FH\^FD2 ea. #00931 Battery/Cartridge Kit^FS
^FT350,460^A0N,27,27^FH\^FD#00602^FS
^FO10,32^GB780,480,8,B,1^FS
^FT720,500^A0N,10,10^FH\^FD[[Date Code]]^FS

 

I want to find any instance of the double brackets regardless of the text in between the brackets. I can find [[SerialNumber 1]] for example, but I also want to scan the whole string and make sure that there are no instances of [[any text]] left in the string. I haven't been able to build a regular expression that will find these.

 

0 Kudos
Message 1 of 5
(3,303 Views)

If you are using the Match Pattern, you can put it inside of a while loop and use the Offset Past Match into a shift register to start looking for the rest.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 5
(3,297 Views)

You are not going to have 1 regular expression to find all instances.  Sicne you got the first message, you have a working regular expression.  Assuming you are using Match Pattern, use the offset past match output to wire into the offset input of the next match pattern.  This will start the search at a certain point in the string (after the match you just found).

 

If you use a while loop, as long as offset past match is >=0, you found a match.  Once it is negative, there was no match.  Pass the offset past match in a shift register which is initialized to 0.

Message 3 of 5
(3,293 Views)
Solution
Accepted by topic author elrathia

Hi elrathia,

  Please find the below screen shot

  Scrrenshot.PNG

Regards,

SrikrishnaNF

Regards,
Srikrishna


Message 4 of 5
(3,274 Views)

All good suggestions. srikrishnaNF's example set me to thinking and I came up with a solution that solved another problem at the same time. Thanks guys.

0 Kudos
Message 5 of 5
(3,242 Views)