mogmismo has asked for the wisdom of the Perl Monks concerning the following question:
So, I'm trying to match, in a string, all values that are abbreviations. In this string:
"a history of u.s. coast guard aviation."
I would like the "u.s." to become "us" but not replace any other periods. Another example would be taking "M.C. Esher" and converting to "MC Esher"
So far, I can remove the middle dot, with a:
$string =~ s/(?<=\w)\.(?=\w)//g;But I can't figure out how to do a lookahead/lookbehind/lookahead/lookbehind... I've tried this, and it fails:
$string =~ s/(?<=\w)\.(?=\w)\.(?=\s)//g;Any ideas, Monks?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Lookahead/Lookbehind Regular Expression...
by Your Mother (Archbishop) on Dec 19, 2013 at 17:37 UTC | |
Re: Lookahead/Lookbehind Regular Expression...
by wind (Priest) on Dec 19, 2013 at 17:35 UTC | |
Re: Lookahead/Lookbehind Regular Expression...
by hdb (Monsignor) on Dec 19, 2013 at 17:15 UTC | |
Re: Lookahead/Lookbehind Regular Expression...
by educated_foo (Vicar) on Dec 20, 2013 at 00:51 UTC |
Back to
Seekers of Perl Wisdom