I'm looking for a regex, which fits to every number, that is made from 0,1,2 and don't have the same digits beside - 02021 fits, 0122 doesn't fit. How it can be written?
You can start with a digit between zero and two. Capture that in a group and check that the following is not the captured value. Capture that in a non capturing group and repeat that.
Explanation
^
(?:
(
[0-2]
)
(?!
)
)
*
$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.