Exemplo n.º 1
0
$r = new Regexp_Assemble(['anchor_word' => 1]);
is($r->add('ab', 'cd', 'ce')->as_string(), '\\b(?:c[de]|ab)\\b', 'implicit anchor word via method');
$r = new Regexp_Assemble(['anchor_word_end' => 1]);
is($r->add('ab', 'cd', 'ce')->as_string(), '(?:c[de]|ab)\\b', 'implicit anchor word end via method');
$r = new Regexp_Assemble(['anchor_word' => 0]);
is($r->add('ab', 'cd', 'ce')->as_string(), '(?:c[de]|ab)', 'no implicit anchor word');
$r = new Regexp_Assemble(['anchor_word' => 1]);
is($r->anchor_word_end(0)->add('ab', 'cd', 'ce')->as_string(), '\\b(?:c[de]|ab)', 'implicit anchor word, no anchor word end');
$r = new Regexp_Assemble();
is($r->anchor_word_begin(1)->add('ab', 'cd', 'ce')->as_string(), '\\b(?:c[de]|ab)', 'implicit anchor word begin');
$r = new Regexp_Assemble();
is($r->add('ab', 'cd', 'ce')->anchor_line()->as_string(), '^(?:c[de]|ab)$', 'implicit anchor line via new');
$r = new Regexp_Assemble();
is($r->add('ab', 'cd', 'ce')->anchor_line_begin()->as_string(), '^(?:c[de]|ab)', 'implicit anchor line via method');
$r = new Regexp_Assemble();
is($r->anchor_line_begin()->anchor_line(0)->add('ab', 'cd', 'ce')->as_string(), '(?:c[de]|ab)', 'no implicit anchor line via method');
$r = new Regexp_Assemble();
is($r->add('ab', 'cd', 'ce')->anchor_string()->as_string(), '\\A(?:c[de]|ab)\\Z', 'implicit anchor string via method');
$r = new Regexp_Assemble();
is($r->add('ab', 'cd', 'ce')->anchor_string_absolute()->as_string(), '\\A(?:c[de]|ab)\\z', 'implicit anchor string absolute via method');
$r = new Regexp_Assemble(['anchor_string_absolute' => 1]);
is($r->add('de', 'df', 'fe')->as_string(), '\\A(?:d[ef]|fe)\\z', 'implicit anchor string absolute via new');
$r = new Regexp_Assemble(['anchor_string_absolute' => 1, 'anchor_string_begin' => 0]);
is($r->add('de', 'df')->as_string(), 'd[ef]\\z', 'anchor string absolute and no anchor_string_begin via new');
$r = new Regexp_Assemble(['anchor_word' => 1, 'anchor_word_end' => 0]);
is($r->add('ze', 'zf', 'zg')->as_string(), '\\bz[efg]', 'anchor word and no anchor_word_begin via new');
$r = new Regexp_Assemble(['anchor_string_absolute' => 0]);
is($r->add('de', 'df', 'fe')->as_string(), '(?:d[ef]|fe)', 'no implicit anchor string absolute via new');
$r = new Regexp_Assemble();
is($r->add('ab', 'cd', 'ce')->anchor_word_begin()->anchor_string_end_absolute()->as_string(), '\\b(?:c[de]|ab)\\z', 'implicit anchor word begin/string absolute end via method');
$r = new Regexp_Assemble();