I am trying to create a regex that selects the longest of two options from a string.
Either a numerical value up to 15 characters long, or any value up to 11 characters long.
So far I have this:
^([0-9]{1,15}|.{1,11})
But, for example, the line: is '7elevenshopfood'shortened to '7', because it looks at the first part of paranthesis. And if I switch it to
^(.{1,11}|[0-9]{1,15})
the string is '123456789123456789'shortened to '12345678912', as it looks again at the first part of the expression.
Anyone with a lot of knowledge of regexp have an idea?
Sonny source
share