[Chicago-talk] Regular expression question

Andrew Rodland arodland at comcast.net
Fri May 1 16:16:32 PDT 2009


On Friday 01 May 2009 06:08:29 pm Michael Potter wrote:
>  Mongers,
>
> What is the cleanest way to combine these three regular expressions:
>
> $Note =~ s/^Eft /EFT /;
> $Note =~ s/ Eft / EFT /;
> $Note =~ s/ Eft$/ EFT/;

This gives _nearly_ the same behavior and might work within your spec:

s/\bEft\b/EFT/;

More complicated and not tested but _should_ match your question exactly:

s/(?:^|(?< ))Eft(?:$|(?= ))/EFT/;

(Whether that's "clean" is up to interpretation...)

Andrew



More information about the Chicago-talk mailing list