kiat has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
Is it possible to have a ternary expression within the replacement bit of the regular expression? I've the following code and I'm trying to fix the size of font (captured in $1) if it's greater than 5:
Thanks in advance :)$message =~ s~\[size=(.+?)\](.+?)\[/size\]~'<font size="' . $1 . '">' + . "$2</font>"~eisg; # I'm trying to test $1 so that if it's greater than 5, # fix it at 5, else leave it unchanged.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Ternary inside a regex
by izut (Chaplain) on Sep 23, 2005 at 12:17 UTC | |
by kiat (Vicar) on Sep 23, 2005 at 12:39 UTC | |
by izut (Chaplain) on Sep 23, 2005 at 12:46 UTC | |
by kiat (Vicar) on Sep 23, 2005 at 13:12 UTC | |
Re: Ternary inside a regex
by blazar (Canon) on Sep 23, 2005 at 15:04 UTC | |
Re: Ternary inside a regex
by ww (Archbishop) on Sep 24, 2005 at 10:45 UTC |
Back to
Seekers of Perl Wisdom