Here's how I do it:
\d{2}(?:(?:[.]{2}|-{2}|_{2})\d{2})+
Explanation: Two digits, followed by one or more occurrences of two identical characters, consisting of a period, hyphen or underscore, and then two more digits.
If you need to fix this, you can add ^
in front and $
at the end.
The reason I prefer to use {2}
instead of writing about myself (that is, repeating the same character) is because it allows you to increase the number. As the number gets larger, counting the number of repeated characters will become more and more difficult.
In addition, depending on your font and screen size, some characters may be visually combined into one long character, making it difficult to figure out how many of them are in sequence. The undescore symbol is a prime example of this, consider: _____
How many underscores are this? Compare and contrast this with this expression: _{5}
source share