I'm trying to create a regex, based off running another set of regexs on a given string.
And basically dynamically come up with a shortened regex that will match the original string.
The problem is i'm seeing an odd behavior.
#!/usr/bin/perl -w my $string = '/path/file.htm?849578345908543095364b892a898374aff849000 +1289384add90e93448a839457582993cde90239a90459c3849aa8374f783477346723 +f38923487dd8923847a892837f783746543ff89283a439823cd948399134452&acces +s_rights=1&mn_ord=yes&session_id=84'; $string =~ s/[^ a-zA-Z0-9_=&\-]/sprintf("\\%s", $&)/eg; # #escape char +s print "$string\n"; #debug $string =~ s/([A-Za-z0-9][^&\/\.]){10,}/sprintf(".*", $&)/eg; $string =~ s/([0-9]){2,}/sprintf("\\d+", $&)/eg; print "\n$string\n";#debug
\/path\/file\.htm\?.*2&access_rights=1&mn_ord=yes&session_id=\d+I'm having difficultly understanding why it wouldn't return
\/path\/file\.htm\?.*&access_rights=1&mn_ord=yes&session_id=\d+
In reply to help in understanding odd regex match by jaco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |