Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Curious Regex

by HamNRye (Monk)
on Feb 11, 2009 at 18:39 UTC ( [id://743126]=note: print w/replies, xml ) Need Help??


in reply to Re: Curious Regex
in thread Curious Regex

Thanks... Yeah, unfortunately the "simpler" method doesn't work because I need to preserve the control chars outside of the tags.

Here's what I have as a "two stage" deal... I was just hoping someone could help me figure out how to make this work as a one liner.

if ($text =~ /<\/Mil[^>]*>(.*)\x9D/i) { my $string = $1; $string =~ s/[\x90\x8F]//g; $text =~ /(<\/Mil[^>]*>).*(\x9D)/$1$string$2/i; }

Replies are listed 'Best First'.
Re^3: Curious Regex
by ELISHEVA (Prior) on Feb 11, 2009 at 18:48 UTC
    Well, basically what you have done is the same idea as what I did except that you have three regex evaluations when only two are needed - you can extract the start tag at the same time as the middle stuff and then put it back together using simple interpolation - which is what I did. Its a bit faster that way, but you should stick with whatever version you will understand three weeks from now.

    As for the one liner - just put it all in a sub - either your version or mine or ikegami's which is even faster - and presto - a one liner. That is what subs are for.

    Best, beth

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-19 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found