in reply to Regex pattern that fails when string contains a certain pattern

Your specification is so vague that it is unlikely that a proposed solution will do what you want even if does pass your five test cases.

Do you mean an undefined separator followed by either a minus or an underscore (or are they your definition of 'separator')? I do not see either in the first test.

Does 'number' mean number as perl defines number or does it mean one decimal digit?

Can we assume that 'any string' does not include the null string?

Your examples of failures should include an explanation of why you expect them to fail.

Bill
  • Comment on Re: Regex pattern that fails when string contains a certain pattern