Pike's-VM matcher: runs a compiled RegexProgram (see "std/text/regex/regex-program") over an input string without backtracking, which bounds matching to O(input length * program size) - no pattern can trigger catastrophic backtracking.
runProgram only tries to match starting exactly at startIndex (i.e. as if the pattern were anchored there); "std/text/regex/regex" implements unanchored search by trying successive start positions.
Try to match prog against input, starting exactly at startIndex (as if the pattern were anchored there - "std/text/regex/regex" tries successive positions to implement unanchored search). On success, returns the capture-slot array (slot 0/1 = whole-match start/end, slot 2g/2g+1 = group g start/end, -1 where a group did not participate).
Parameters
Name
Type
Description
prog
const RegexProgram&
Compiled program to run
input
const String&
String to match against
startIndex
unsigned long
Position in input to start matching at
Returns:Optional<Vector<long>> — The capture-slot array of the match with the greatest extent under Perl/PCRE-style leftmost-first priority, or an empty Optional if no match starts at startIndex