Reputation: 463
I need a regex which matches with 1 to 6 length digits which is easy \d{1,6}
, however I need avoid if there is longer number than 6 digits.
For example, it should match 233
in sentence, my id is 233
, but it should not match my id is 222334444
It should only match if there is space before first digit of number.
Thanks
Upvotes: 1
Views: 1990
Reputation:
Its hard to tell what the expected character is on either side.
Generally, it could be done using word boundary \b\d{1,6}\b
Upvotes: 1