Answer the question
In order to leave comments, you need to log in
How to iterate over all pairs in a string?
Hello!
Please help me to "stick" once =)
We need to replace all pairs (sharp between numbers) in the string.
So that
8-911-1234567
8-495-1-234-zzz
... becomes this:
8|911|1234567
8|495|1|234 -zzz Tried
:
([0-9.]+)\-
== = -zzz picks up, but should not
(([0-9.]+)\-)+([0-9]+)
=== glues all sequences into one line and only splits the tail into a pair
https://regex101 .com/r/qF7vT8/63
Answer the question
In order to leave comments, you need to log in
Here, either a negative lookahead (choose a dash) /-(?![a-z])/
https://regex101.com/r/czLHsu/1/
Or in this way: /\d+(-[a-z]+)?/
https://regex101.com/r/lEEC52/1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question