Home > Software engineering >  Regex match 2 letters and up to 10 digits afterwards
Regex match 2 letters and up to 10 digits afterwards

Time:10-01

I have the following regex which is matching the first 2 letters RR and then 4 numbers after.

RR[0-9]{4}

How can I change it to detect the first 2 letters RR and then up to 10 digits afterwards?

I know I can do...

^[0-9]*$

To match all numbers but how can I limit this and add it to the first regex?

CodePudding user response:

You can use RR\d{0,10}. This matches RR, followed by 0 to 10 digits, i.e. up to 10 digits.

  • Related