mirror of
https://github.com/corda/corda.git
synced 2025-01-24 13:28:07 +00:00
62d1964779
A program for the PikeVM corresponds to a regular expression pattern. The program matches the character sequence in left-to-right order. However, for look-behind expressions, we will want to match the character sequence backwards. To this end, it is nice that regular expression patterns can be reversed in a straight-forward manner. However, it would be nice if we could avoid multiple parsing passes and simply parse even look-behind expressions as if they were look-ahead ones, and then simply reverse the program for that part. Happily, it is not difficult to reverse the program so it is equivalent to matching the pattern backwards. There is one catch, though. Imagine matching the sequence "a" against the regular expression "(a?)a?". If we match forward, the group will match the letter "a", when matching backwards, it will match the empty string. So, while the reverse pattern is equivalent to the forward pattern in terms of "does the pattern match that sequence", but not its sub-matches. For that reason, Java simply ignores capturing groups in look-behind patterns (and for consistency, the same holds for look-ahead patterns). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> |
||
---|---|---|
.. | ||
CharacterMatcher.java | ||
Compiler.java | ||
Matcher.java | ||
Pattern.java | ||
PikeVM.java | ||
PikeVMOpcodes.java | ||
RegexMatcher.java | ||
RegexPattern.java | ||
TrivialMatcher.java | ||
TrivialPattern.java |