searchFull() public method

Advances the scan pointer if $advance_pointer, otherwise not. Returns the matched string if $return_string is true, otherwise returns the number of bytes advanced. This method does affect the match register.
public searchFull ( string $pattern, boolean $advance_pointer, boolean $return_string ) : mixed
$pattern string The regular expression
$advance_pointer boolean Wheter to update the pointer or not
$return_string boolean Wheter to return the matched string or the position
return mixed Either the matched string (if $return_string is true) or the end position of the match
Example #1
0
 function testSearchFull()
 {
     $sc = new StringScanner("foobar blorg bla");
     $res = $sc->searchFull("hahaha", false, false);
     $this->assertEqual($res, null);
     $res = $sc->searchFull("bar", false, false);
     $this->assertEqual($res, 6);
     $this->assertEqual($sc->rest(), "foobar blorg bla");
     $this->assertEqual($sc->getMatched(), "bar");
     $res = $sc->searchFull("bar", true, false);
     $this->assertEqual($res, "foobar");
     $this->assertEqual($sc->rest(), "foobar blorg bla");
     $this->assertEqual($sc->getMatched(), "bar");
     $res = $sc->searchFull("(bar)(\\s+)", true, true);
     $this->assertEqual($res, "foobar ");
     $this->assertEqual($sc->rest(), "blorg bla");
     $this->assertEqual($sc->getMatched(), "bar ");
     $this->assertEqual($sc[0], "bar ");
     $this->assertEqual($sc[1], "bar");
     $this->assertEqual($sc[2], " ");
 }