I’m trying to verify a string matches a certain pattern:
#:XY1:XY2:ABC:::xy::
The part #:XY1 is required, the fields and separators after that are optional. But if the third field is there, it has to be ABC. I am trying it like this:
^#:[^:]+:?([^:]+)?:?(ABC)?:?([^:]*:?)*$
But it matches also lines, which don’t exactly have ABC as third field.
Please try this: