Reputation: 531
I need some pointers with some regex voodoo - I just don't use them enough day to day to be familiar with them.
I'm processing a string containing multiple words and need to look for a reference number.
The ref number is in the format LCSYK89HE4W4 . 'LCS' is always constant, the Ref is always 12 chars long. The rest of the ref is made up from random uppercase alphanumeric chars.
Examples:
LCSJKIIU786T
LCS5YU87TFR4
LCSKIJ5R67DE
Any pointers would be much appreciated.
Thanks Sam
Upvotes: 3
Views: 1961
Reputation: 476554
Use the following regex
LCS[0-9A-Z]{9}
Using this string however, it happens that a line containing additional characters before and after will not be rejected. If the string should begin and end with the ref number, use
^LCS[0-9A-Z]{9}$
You can test the regex here http://phpregextester.com/ (use /LCS[0-9A-Z]{9}/
)
Upvotes: 5