Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Regex::Reverse tricky test cases

by dragonchild (Archbishop)
on May 17, 2005 at 12:46 UTC ( [id://457773]=note: print w/replies, xml ) Need Help??


in reply to Regex::Reverse tricky test cases

Why would you want to reverse a regex? Isn't $string =~ reverse(qr/.../) the same as reverse(reverse($string) =~ qr/.../);?

  • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
  • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"

Replies are listed 'Best First'.
Re^2: Regex::Reverse tricky test cases
by Roy Johnson (Monsignor) on May 17, 2005 at 13:11 UTC
    sexeger.

    Some patterns — notably those with negative lookbehinds, which cannot be variable-length, but also others — work better backwards. Yes, you have to reverse the string to be matched, as well as the regex, and then you have to reverse whatever you captured. Sometimes it's still a win.


    Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-16 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found