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