Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^5: Regular Expression Translation Help!

by kennethk (Abbot)
on Nov 30, 2010 at 21:23 UTC ( [id://874575]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Regular Expression Translation Help!
in thread Regular Expression Translation Help!

I'm having some trouble understanding the question here, so I will list off some possible inputs and what the output from the conditional operator would be.
  • USA111 => 111
  • BRA111 => 111
  • BRA2#$ => 2#$
  • ABC111 => ABC111
  • USAabcXY => abc
  • usa111xy => usa111xy

In cases where the string changes, the regular expression matched and the result is what was stored in $2. In cases where the string didn't change, the regular expression did not match.

Replies are listed 'Best First'.
Re^6: Regular Expression Translation Help!
by aquarium (Curate) on Nov 30, 2010 at 23:34 UTC
    and if i'm reading the regex context correctly, if there's no match at all, then the string sent for matching is returned intact without changes.
    my personal preference would be for a code block that is a bit clearer, as combining the search & replace regex and the trinary conditional operator makes it a bit confusing.
    the hardest line to type correctly is: stty erase ^H

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-24 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found