$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(); is($r->add('ab', 'ad')->anchor_string(1)->anchor_string_end(0)->as_string(), '\\Aa[bd]', 'explicit anchor string/no end via method'); $r = new Regexp_Assemble(); is($r->anchor_string_end()->add('ab', 'ad')->as_string(), 'a[bd]\\Z', 'anchor string end via method'); $r = new Regexp_Assemble(); is($r->anchor_string_absolute(1)->add('ab', 'ad')->as_string(), '\\Aa[bd]\\z', 'anchor string end via method'); $r = new Regexp_Assemble(['anchor_word_begin' => 1, 'anchor_string_end_absolute' => 1]); is($r->add('de', 'ad', 'be', 'ef')->as_string(), '\\b(?:[bd]e|ad|ef)\\z', 'implicit anchor word begin/string absolute end via new'); $r = new Regexp_Assemble(); is($r->add('ab', 'cd', 'ce')->anchor_word_begin()->anchor_string_begin()->as_string(), '\\b(?:c[de]|ab)', 'implicit anchor word beats string'); /* TODO: { // use vars '$TODO'; // local $TODO = "\\d+ does not absorb digits"; $r = new Regexp_Assemble(); is( $r->add( '5', '\\d+' )->as_string(), '\\d+', '\\d+ absorbs single char' );