Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Yet another regex question

by injunjoel (Priest)
on Aug 25, 2005 at 17:10 UTC ( #486640=note: print w/replies, xml ) Need Help??


in reply to Yet another regex question

Greetings all,
Update a better way to do it.(than I had previously posted)
Though only tested on a simple case the following should get you your global replace you were looking for.
$str =~ s/if substr\(([^\)]*)\) in (\([^\)]*\))/my($f,$s)=($1,$2); $f= +~s!^!\$!; $s=~s!\D!!g; "if substr($f) =~ m#[$s]#"/eg;
yet another way to do it.
$str =~ s/in/=~/; $str =~ s/(?:\s)(\([^\)]*\))/my $s=$1;$s=~s!\D!!g;" m#[$s]#"/e;

Which outputs
if substr(acct_trtmt_hsty,1,1) =~ m#[789]#;
from your original string.


-InjunJoel
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2019-07-17 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?