I analyzed these two regexes using regex101. I think the backtrack of /\S+:/
is right. But I can't understand that difference. Am I wrong?
While this appears to be implementation specific (RegexBuddy doesn't show this behavior), it can be explained as follows:
\w
can't match :
, but \S
can. Therefore, \S+:
needs to check more variations of the input string before making sure that get
can't match it.
More optimized regex engines will exclude impossible matches faster (e. g., when the regex contains a literal character that isn't present in the current part of the match), but apparently the engine that regex101 is using isn't doing that.