When a regex is anchored to the start of a subject, there's no need to search throughout a string for the pattern when searching for the first match: a prefix match is sufficient.
This adds a regex compilation-time check about whether a match can only be found at the start of a subject, and then uses that to choose whether to defer to prefixMatch from within firstMatch.
When a regex is anchored to the start of a subject, there's no need to search throughout a string for the pattern when searching for the first match: a prefix match is sufficient.
This adds a regex compilation-time check about whether a match can only be found at the start of a subject, and then uses that to choose whether to defer to
prefixMatch
from withinfirstMatch
.(This is a cherry-pick of #682.)