"be consistent" | |
PerlMonks |
Re: Perl replacement for choice.comby Athanasius (Archbishop) |
on Mar 02, 2013 at 07:21 UTC ( [id://1021396]=note: print w/replies, xml ) | Need Help?? |
A comment on the regexen:
Actually, there is no capturing being done in the first regex; the parentheses are there only for grouping, i.e. to show where the positive look-behind assertion ends. (Try adding a $1 to the replacement part, and you will get a series of error messages beginning Use of uninitialized value $1.) The first regex could also be written as:
which does capture each character. The two regexen can be combined into one using a negative look-ahead assertion:
See “Look-Around Assertions” under Extended Patterns in perlre. Hope that helps,
In Section
Cool Uses for Perl
|
|