LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with a regex

Solved!
Go to solution

I have a Zebra printer string I want to parse out some information from, but I can't get a single regex to do it.

 

The string is like the following;

 

^FT342,695^A0N,83,81^FH\^FDS/N : [[WIDGET]]^FS

^FT793,1170^A0N,67,67^FH\^FD1 ea. #00123 Widget^FS

 ^FT793,1170^A0N,67,80^FH\^FD2 ea. #00456 Widget Deluxe^FS

 ^FT793,1170^A0N,67,90^FH\^FD#0789^FS

 

I want what is in red. It will vary from label to label. I will use the results to display to the user which label he is printing. What is in blue doesn't vary, if that helps any.

 

Thanks for any help!

0 Kudos
Message 1 of 9
(4,525 Views)

Here is a fast way to get the last portion of the label format. You would still need to do something to ignore the first entry which you indicated you didn't care about.

 

Parse Label.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 9
(4,511 Views)
Solution
Accepted by elrathia

Here would be a way using regular expressions. Again, you will need to ignore the first entry and this version will add an empty entry in the last position of the array. You wil have more entries if your label contains more than what you posted..

 

Parse Label (Regex).png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 3 of 9
(4,500 Views)

I didn't know about using the regex option for search and replace until seeing Darin's example posted here.

 

There are probably more robust regex strings that could be used, but this example works...

 

Extract Label Data.png

 

Message 4 of 9
(4,470 Views)

I posted it in the regular expressions thread 🙂

0 Kudos
Message 5 of 9
(4,457 Views)

Mark,

 

You put a colleague and I on the right track. We came up with this, that ignores the lines without the # sign. The blank entry at the end of the array is no problem.

 

 

Regex Solution.png

 

 

 

Not sure why the FD and FH have to be [F][H] and not [FH], but it works. Thanks to all. And where is the regex thread? I couldn't find it.

0 Kudos
Message 6 of 9
(4,446 Views)

Here is a link to the Regular Expressions thread:

http://forums.ni.com/t5/BreakPoint/Regular-Expressions-Board/td-p/1187799

Message 7 of 9
(4,438 Views)

Oh wow! Whole bunch of new stuff! I thought that board had to do with some kind of hardware called Breakpoint. 🙂

0 Kudos
Message 8 of 9
(4,432 Views)

That's where you go when you need to take a break... You can discuss anything, even giving someone a bunch of Kudos 😉

Message 9 of 9
(4,423 Views)