I want to match
123-123
or
123-123_123-123
I do not want to match
123_123
or
123-123 not underscore 123-123
or
123--123
I tried
(\d+)-(\d+)
You could try this:
/^(?:(\d+)-(\d+)_(\d+)-(\d+))$|^(?:(\d+)-(\d+))$/
Working example based on your input here: https://regex101.com/r/1GOOzQ/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.