Naive implementation of what you want:
^(0|[1-9]\d*)\.(\*|(0|[1-9]\d*)\.(\*|(0|[1-9]\d*)))(\r)?$
I got it by following such conclusions. First we create a regular checker that checks the string against the ABC pattern, it is simple:
^\d+\.\d+\.\d+(\r)?$
here \d+ is any number sequence, \. - point (must be escaped, yes), ^ - the beginning of the line, (\r)?$ - the end of the line, taking into account both \r\n , and just \n
Further, instead of the last block of digits, there can be a single asterisk, replacing \d+ with (\*|\d+) (the asterisk must also be escaped):
^\d+\.\d+\.(\*|\d+)(\r)?$
Also, the asterisk can be instead of the last two blocks, similarly to the previous one, change \d+\.(\*|\d+) to (\*|\d+\.(\*|\d+)) :
^\d+\.(\*|\d+\.(\*|\d+))(\r)?$
Well, it remains to exclude numbers with leading zeros, i.e. This is either a separate zero 0 , or non zero + any number of digits [1-9]\d* . Replace all three blocks \d+ with a construction (0|[1-9]\d*) , we get the final version.