print "3A\n"; $parser = new RegexParser("#^boo#"); var_dump($parser->match("boo", 0) === array("j" => 3, "value" => "boo")); try { $parser->match("aboo", 0); var_dump(false); } catch (ParseFailureException $e) { var_dump(true); } var_dump($parser->match("aboo", 1) == array("j" => 4, "value" => "boo")); $parser = new RegexParser("#^-?(0|[1-9][0-9]*)(\\.[0-9]*)?([eE][-+]?[0-9]*)?#"); var_dump($parser->match("-24.444E-009", 2) === array("j" => 12, "value" => "4.444E-009")); print "5A\n"; $parser = new Utf8Parser(array()); try { $parser->match("", 0); var_dump(false); } catch (ParseFailureException $e) { var_dump(true); } var_dump($parser->match("A", 0) === array("j" => 1, "value" => "A")); # 1-byte character "A" var_dump($parser->match("¯", 0) === array("j" => 2, "value" => "¯")); # 2-byte character "¯" var_dump($parser->match("♥", 0) === array("j" => 3, "value" => "♥")); # 3-byte character "♥" var_dump($parser->match("", 0) === array("j" => 4, "value" => "")); # 4-byte character "" var_dump($parser->match("", 0) === array("j" => 3, "value" => "")); # "byte order mark" 11101111 10111011 10111111 (U+FEFF) var_dump($parser->match("𐀀", 0) === array("j" => 4, "value" => "𐀀"));