Adverb Types
It is important to understand that there are two different types of repressive dialects:
- Those that fine tune how your regular expression code is compiled (
:sigspace / :s :ignorecase / :i , ...). They can also be written inside the regular expression and apply only to the rest of their lexical area within the regular expression. - Those that control how regular expression matching is found and returned (for example
:exhaustive / :ex :exhaustive :overlap / :ov :exhaustive :global / :g ). They are applied to the given regular expression matching operation in general and should be written outside the regular expression as an adverb of the operator m// or .match .
Matching Adverbs
Here's what the second type of adverbs do:
m:ex/.../ finds every possible match in all possible starting positions.m:ov/.../ finds the first possible match at each possible starting position.m:g/.../ finds the first possible match in each possible starting position that comes after the end of the previous match (that is, it does not overlap).m/.../ finds a possible match first at the starting position of the first .
(In each case, the regex engine moves as soon as it discovers that it should have been found at any given position, so you don’t see any additional output, even if you put print statements inside regexes.)
Your example
In your case, there are only two possible matches: ab|c and a|bc .
Both start at the same position in the input line, namely at position 0.
Thus, only m:ex/.../ will find both of them: ndash; all other options will find only one of them, and then go over.
source share