Problem with regex followed by string

I have a problem with RegexSet. I have the following two regex in the set

  r"Gobo\d{1,}",
  r"Gobo\d{1,}SelectSpin",

When I test the regex with

"Gobo12"

it matches the first one as expected

When I test the regex with

"Gobo12SelectSpin"

it machtes both but I would expect to match only on the second.

What is wrong with my Regex?

A regular expression like that matches anywhere in the string.
Gobo12SelectSpin therefore does match r"Gobo\d{1,}" just fine.

If you need to match from the beginning of a line/string you need to use ^ or \A.
Or $ / \Z for end of line/string.
See Empty Matches.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.