Saturday 15 May 2010

How do I write in regex: the previous pattern cannot appear in the rest of the line? -



How do I write in regex: the previous pattern cannot appear in the rest of the line? -

i match string different numbers in them separated text

for illustration match strings like: hello 42 here next number 43 numbers can cannot same.

and not match strings like: hello 42 here next number 42 numbers same.

this should work -

\d+(\d+)\d+(?:(?!\1)\d+)

demo here

regex

No comments:

Post a Comment