The regex matches the following space and numbers

I've searched around a bit, but I haven't found a solution for my problem yet.

I am 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 cannot add a space, then a number, then a space, and finally a digit. How could I achieve this?

+3


source to share


3 answers


Are you looking for something like

[A-Z]+(?:\s+[0-9]+)+

      

Watch the demo

Or if there are 2 sets of number groups after the word, and the 1st number is 6 digits, and the last digit is always 1:



[A-Z]+\s+[0-9]{6}\s+[0-9]\b

      

Demo 2

The option i

will also match words with lowercase letters.

+2


source


Are you looking for this regex?

\b(YOUU|MEIU)\s+\d+\b\s+\d

      



if the numbers in the middle are always 6 numbers, you can fix that with

\b(YOUU|MEIU)\s+\d{6}\b\s+\d

      

+1


source


Try using this:

\b(YOUU|MEIU) \d+ \d\b

      

REGEX DEMO

+1


source







All Articles