Using simple regexp with re2j library with Spring (Java) project. In debug mode I found out that pattern:
^[0-9a-fA-F:]+$
It compiled, but failed to recognize text:
123ABC:DEF456
0:1:2:3:4:5
12345
90210-1234
Expecting that pattern matched text, but hasMatch = false
I see multiple problems with your current pattern. First, it appears that the separator character could be either
:
or-
, but your pattern only caters to the former. Also, if you want to match many such strings across multiple lines, then you need to take that into account.Try this version:
Demo
If you only need to match one line at time, then simplify to: