in reply to Regular Expression: search two times for the same number of any signs
Hi
I would recommend to create the regular expression dynamically, based on the length of the input-string (or on the last "x"). It could somehow look like this:
my $s = "x12345x23x56x"; my $len = (length($s)-3)/2; my $re = "x" . "."x$len . "x" . "."x$len . "x"; # this is the RegEx +you want if ($s =~ /$re/) { print "ok\n"; } else {print "nok\n";}
HTH, Rata
|
---|
In Section
Seekers of Perl Wisdom