Reputation: 53
I have searched around quite a bit, but I haven't found a solution for my problem yet.
I'm trying to create a regex that will allow me to match the following examples:
YOUU 410831 0
MEIU 810851 0
I got to \b(YOUU|MEIU)\w*\b
.
But then I can't seem to add a space, then a number, then a space again, and finally a digit. How could I achieve this?
Upvotes: 3
Views: 73
Reputation: 8169
You are probably looking for this regex?
\b(YOUU|MEIU)\s+\d+\b\s+\d
if the numbers in the middle are always 6 numbers, you may want to fix that with
\b(YOUU|MEIU)\s+\d{6}\b\s+\d
Upvotes: 1
Reputation: 627103
You are looking for something like
[A-Z]+(?:\s+[0-9]+)+
Or, if there are 2 set groups of numbers after the word, and the 1st number is 6 digits in size, and the last digit is always of size 1:
[A-Z]+\s+[0-9]{6}\s+[0-9]\b
With i
option, the words with lowercase letters will also be matched.
Upvotes: 2