0

I have been working on an regular expression which say consists of more than 9 digits ( 12345678910111213 )

With the help of regex \d{9}(?!\d) i am able to find the last 9 digits of the number.

But when the entire number is less than 9 digits how do i take the entire number as pass it. is there any such regular expression.

Wiktor Stribiżew
  • 561,645
  • 34
  • 376
  • 476

1 Answers1

2

\d{1,9}(?!\d) will take as many as possible from the end, up to 9.

tripleee
  • 158,107
  • 27
  • 234
  • 292