|
|
@ -105,23 +105,7 @@ The key differences are mentioned below.
|
|
|
|
|
|
|
|
|
|
|
|
1. Greediness:
|
|
|
|
1. Greediness:
|
|
|
|
|
|
|
|
|
|
|
|
This engine does not support non-greedy operators. All operators are always greedy in nature, and will try
|
|
|
|
This engine currently does not support non-greedy operators.
|
|
|
|
to match as much as they can, while still allowing for a successful match. For example, given the regex:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
y*y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The engine will match as many 'y's as it can, while still allowing the trailing 'y' to be matched.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Another, more subtle example is the following regex:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x|xx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
While the stdlib implementation (and most other engines) will prefer matching the first item of the alternation,
|
|
|
|
|
|
|
|
this engine will go for the longest possible match, regardless of the order of the alternation. Although this
|
|
|
|
|
|
|
|
strays from the convention, it results in a nice rule-of-thumb - the engine is ALWAYS greedy.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The stdlib implementation has a function [regexp.Regexp.Longest] which makes future searches prefer the longest match.
|
|
|
|
|
|
|
|
That is the default (and unchangable) behavior in this engine.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2. Byte-slices and runes:
|
|
|
|
2. Byte-slices and runes:
|
|
|
|
|
|
|
|
|
|
|
|