Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
more useful options
 
PerlMonks  

Re^2: Ternary inside a regex

by kiat (Vicar)
on Sep 23, 2005 at 12:39 UTC ( #494504=note: print w/ replies, xml ) Need Help??


in reply to Re: Ternary inside a regex
in thread Ternary inside a regex

Thanks, izut!

Changed my code to the following and it works:

$message =~ s~\[size=(.+?)\](.+?)\[/size\]~($1 > 5) ? "<font size=\"5\ +">$2</font>" : "<font size=\"$1\">$2</font>"~eisg;


Comment on Re^2: Ternary inside a regex
Download Code
Re^3: Ternary inside a regex
by izut (Chaplain) on Sep 23, 2005 at 12:46 UTC
    I think this way is easier to read:
    message =~ s~\[size=(.+?)\](.+?)\[/size\]~"<font size=\"".(($1 > 5) ? +5 : $1)."\>$2</font>"~eisg;


    Igor S. Lopes - izut
    surrender to perl. your code, your rules.
      Nice! I wanted to do that but didn't manage to - I didn't have the parentheses.

      Thanks :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (16)
As of 2014-04-17 13:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (447 votes), past polls