in reply to String similarities and pattern matching
Just a thought:
#! /usr/local/bin/perl -w use Regexp::Assemble; my $ra = Regexp::Assemble->new->add( 'Error 123 on SystemA file not found error', 'Error 123 on SystemB file not found error', 'Error 123 on SystemC file not found error' ); print $ra->re;
Produces:
(?-xism:Error 123 on System[ABC] file not found error)
And:
#! /usr/local/bin/perl -w use Regexp::Assemble; my $ra = Regexp::Assemble->new->add( 'Error 124 on User1:FileA no space left', 'Error 124 on User2:FileB no space left', 'Error 124 on User3:FileC no space left' ); print $ra->re;
Outputs:
(?-xism:Error 124 on User(?:1:FileA|2:FileB|3:FileC) no space left)
See also:
Regexp::Assemble
grinder's scratchpad
Why machine-generated solutions will never cease to amaze me
HTH,
|
|---|