Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Regular Expression: search two times for the same number of any signs

by Ratazong (Monsignor)
on Nov 29, 2016 at 10:17 UTC ( #1176779=note: print w/replies, xml ) Need Help??


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

  • Comment on Re: Regular Expression: search two times for the same number of any signs
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1176779]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2020-06-02 09:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (16 votes). Check out past polls.

    Notices?