in reply to Is regex 1 covered by regex 2
There is probably no simple solution as the regexes can look very different but mean (nearly the same), like /\d/ and /[0-9]/. You could check for the similarity of the regexes when seeing them as strings:
use strict; use warnings; use Text::Levenshtein 'distance'; my @old = ( 'abc.*f', 'hello world\d', '1234' ); my $new = 'abcd.*f'; for (@old) { print "Warning: $new looks like $_\n" if distance( $new, $_ ) < 6; }
There are a lot of possible measures of distance around.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is regex 1 covered by regex 2
by ww (Archbishop) on Apr 29, 2015 at 11:48 UTC | |
by Jenda (Abbot) on Apr 29, 2015 at 14:56 UTC | |
by hdb (Monsignor) on Apr 29, 2015 at 12:17 UTC |