Reputation: 7
I require regular expression to match for number range starting with 4, next 5 or 6 then 8 digits.
I wrote the following RegEx:
^.*(4[5-6][0-9]{8}).*$
Examples: Input = 4600004785/0010
return substitute $1 = 4600004785
Input = N°4500648235
return substitute $1 = 4500648235
But how to retrieve the same number range if the Input contains spaces between the number like:
Input = N° 45 00 64 82 35
substitute = 4500648235
I found a RegEx to remove the spaces between digits but i don't understand how to mix both
(\d)(?= \d)
Thanks
Upvotes: -1
Views: 65
Reputation: 18631
Use
^.*?(4) ?([56]) ?(\d) ?(\d) ?(\d) ?(\d) ?(\d) ?(\d) ?(\d) ?(\d).*
See regex proof.
Upvotes: 2