Regular expression that returns next words

0

Well I'm working on a regular expression that picks up license plates, my interest would be not to just pick up the plates, but like things close to it, for example:

|Placa:AVX-4300 Fiat Uno |     

Here is the expression that I am using [A-Z]{3}-[0-9]{4} , who can help me.

    
asked by anonymous 11.03.2018 / 20:45

1 answer

1

You can use this regex:

[A-Z]{3}-[0-9]{4}\s\w+\s\w+

I just added \s\w+\s\w+ which will capture next to the board plus two strings (containing letters, numbers or underscore ) separated by space ( \s ). / p>

If you want to include a hyphen in the search, it would be:

[A-Z]{3}-[0-9]{4}\s[\w-]+\s[\w-]+

View on Ideone

    
12.03.2018 / 00:01