exilepanda has asked for the wisdom of the Perl Monks concerning the following question:
$who = $name || '(unknown)'; $greet = "#{getName($who)}#"; $greet =~ s{#\{(\w+)\(([^\)]+)\)\}#}{$obj->{"$1"}->($2)}eg;
my logic is to look for a ( to start, and read until I found a ) to end. This will be no problem if $name is in a normal status, however, if $name goes to (unknown), then my s regex will not be working. I believe I can make the string become '(unknown\)' can help somehow, but then I have no idea on the regex, while I can looking for ) and ignore \) at the same time.
Please let me know if I didn't state my question making sense. Any clues ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to cater a self defined escape char in regex ?
by Loops (Curate) on Apr 08, 2013 at 10:07 UTC | |
by exilepanda (Friar) on Apr 08, 2013 at 17:08 UTC | |
|
Re: How to cater a self defined escape char in regex ?
by hdb (Monsignor) on Apr 08, 2013 at 10:16 UTC | |
by exilepanda (Friar) on Apr 08, 2013 at 17:42 UTC | |
|
Re: How to cater a self defined escape char in regex ?
by aitap (Curate) on Apr 08, 2013 at 12:34 UTC | |
by exilepanda (Friar) on Apr 08, 2013 at 17:36 UTC |