Beispiel #1
0
$s->string($string);
assert($s->peek() === '0');
assert($s->peek(1) === '0');
assert($s->peek(2) === '01');
assert($s->peek(20) === $string);
assert($s->get() === '0');
assert($s->get(1) === '1');
assert($s->get(2) === '23');
assert($s->rest() === '456789');
assert($s->get(20) === '456789');
assert($s->eos());
assert($s->rest() === '');
$s->reset();
assert($s->pos() === 0);
// test scan and match_* functions, and unscan
assert($s->scan('/\\d/') === '0');
assert($s->pos() === 1);
assert($s->match() === '0');
assert($s->matchGroup(0) === '0');
assert($s->matchGroups() === array(0 => '0'));
assert($s->scan('/(?P<one>\\d)\\d{2}.(\\d(\\d))/') === '123456');
assert($s->matchGroup(0) === '123456');
assert($s->matchGroup('one') === '1');
assert($s->matchGroup(2) === '56');
assert($s->matchGroup(3) === '6');
assert($s->matchPos() === 1);
assert($s->pos() === 7);
$s->unscan();
//repeat
assert($s->pos() === 1);
assert($s->match() === '0');