LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write this string as a regular expression format?

The string format is YYWWPXXXXM

YY-YEAR

WW-WEEK

P-PRODUCT

XXXX-BATCH NUM

M-MANUFACTURER

 

Examples are 2123A3456G, 2111G3463H, or 2019C4928P.

Since this is a mix of letters and numbers, how would I write this as a regular expression?

0 Kudos
Message 1 of 5
(1,554 Views)

@mshaske wrote:

The string format is YYWWPXXXXM

YY-YEAR

WW-WEEK

P-PRODUCT

XXXX-BATCH NUM

M-MANUFACTURER

 

Examples are 2123A3456G, 2111G3463H, or 2019C4928P.

Since this is a mix of letters and numbers, how would I write this as a regular expression?


You're trying to pick this out of a larger string?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 5
(1,550 Views)

If that's all you're receiving, it's easier just to chop that up by offset.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 5
(1,548 Views)

With the Scan From String VI, you can use this format string, as long as there are no letters that will appear in the year, week or batch num fields.

%2d%2d%1s%4d%1s

aputman
0 Kudos
Message 4 of 5
(1,538 Views)

If you're trying to parse each subfield, use aputman's Scan From String advice. If you're trying to ID your string in a big list of other strings, use this regex:

 

[0-9]{2}[0-9]{2}[a-zA-Z][0-9]{4}[a-zA-Z]

 

(Tip, use https://regex101.com/ to check)

0 Kudos
Message 5 of 5
(1,526 Views)