skipPattern method
- Pattern p
Match p
at the text directly after the cursor and skip over the match if it exists, else
return null
.
You might also be interested in:
- skipWhitespace, for skipping arbitrary spans of whitespace.
- skipString, for skipping arbitrary strings.
Implementation
Match? skipPattern(Pattern p) {
Match? match = p.matchAsPrefix(buffer.substring(index));
if (match != null) {
history.add(index);
// The end of the match is the same as its length since it was matched as a prefix.
index += match.end;
}
return match;
}