First, you shouldn't use all that alternation, it's much slower (and
harder to read) than a character class. Second, you want to have a
so called
zero width negative lookahead. You want to make sure
that what follows doesn't match some regular expression. Third, don't
use
\1 in the replacement, use
$1.
$f =~ s/\s([iaeouyE]):(?!\S)/ $1/;
Replace a whitespace, a vowel, and a colon, not followed by something
that isn't whitespace, with a space and said vowel. Alternatively, if
you know the first whitespace is always a space (or if you just want
to keep whatever whitespace it was), you could use a
zero width positive
lookbehind:
$f =~ s/(?<=\s[iaeouyE]):(?!\S)//;
The
(?<= ) construct is the lookbehind. There's more about
lookaheads and lookbehinds in the
perlre manual page.
-- Abigail
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.