<?php require_once "Regexp_Assemble.php"; for ($i = 0; $i < 10000; ++$i) { $reg = new Regexp_Assemble(); $reg->add('神岸あかり'); $reg->add('赤座あかり'); $reg->add('黒座あかり'); $str = $reg->re(); $reg = new Regexp_Assemble(); $reg->add('スティーブ・ジョブズ'); $reg->add('スティーブ・ウォズアニック'); $str = $reg->re(); $reg = new Regexp_Assemble(); $reg->add('お兄ちゃま'); $reg->add('あにぃ'); $reg->add('お兄様'); $reg->add('おにいたま'); $reg->add('兄上様'); $reg->add('にいさま'); $reg->add('アニキ'); $reg->add('兄くん'); $reg->add('兄君さま'); $reg->add('兄チャマ'); $reg->add('兄や'); $str = $reg->re(); }
} my $PERL_VERSION_TOO_LOW = ($] < 5.007); my $PERL_VERSION_5_005 = ($] < 5.006); use Regexp::Assemble; my $fixed = 'The scalar remains the same'; $_ = $fixed; */ $ra = new Regexp_Assemble(); is_deeply($ra->__mbegin, [], 'mbegin is [] on non-tracked R::A object'); is_deeply($ra->__mend, [], 'mend is [] on non-tracked R::A object'); $re = new Regexp_Assemble(); $re->add('cat')->add('dog'); $regexp = $re->re(); ok($re->match('cat'), 'match without tracking'); ok(!$re->match('eagle'), 'match fail without tracking'); $re = new Regexp_Assemble(); $re->track(1)->add('dog'); ok($re->match('dog'), 're pattern-0 dog match'); is($re->source(0), 'dog', 'source is dog'); $re = new Regexp_Assemble(['track' => 1]); $re->add('dog', 'dogged', 'fish', 'fetish', 'flash', 'fresh'); $re->add('foolish-\\d+'); ok($re->match('dog'), 're pattern-1 dog match'); // SKIP: { // skip( "matched() is not implemented in this version of perl ($])", 1 ) if $PERL_VERSION_TOO_LOW; is($re->matched, 'dog', 're pattern-1 dog matched'); // } ok($re->match('dogged'), 're pattern-1 dogged match');
// $r->__flags = '-xism'; } $args = '(' . join(') (', $test) . ')'; if (count($param)) { $args .= '{'; foreach ($param as $key => $value) { $args .= "{$key} => {$value} ,"; } $args .= '}'; } is($r->re(), $result, "add {$args}"); } $r = new Regexp_Assemble(); $r->__flags = '-xism'; $r->add('de'); $re = $r->re(); is("{$re}", "(?{$xism}de)", 'de'); $re2 = $r->re(); is("{$re2}", "(?{$xism}de)", 'de again'); $r = new Regexp_Assemble(['lookahead' => 1]); is($r->add('car', 'cart', 'card', 'carp', 'carion')->as_string(), 'car(?:(?=[dipt])(?:[dpt]|ion))?', 'lookahead car carp cart card carion'); $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');