in reply to Re: finding nonword character at end of strings
in thread finding nonword character at end of strings

Good try, but you cannot use "end of string" in a character class. Also, the parser sees $] as a variable and cannot find the closing brace.

Try this one:

$f =~ s/\s(i|a|e|o|u|y|E):(\s|$)/ $1$2/;
It also captures the space or end of string and uses that rather than a space: this may or may not be what you want.

-- iakobski

Replies are listed 'Best First'.
Re: Re: finding nonword character at end of strings
by Hofmator (Curate) on Jun 26, 2001 at 14:51 UTC

    In your solution the $ in the character class uses its special meaning and becomes a literal '$'. You have to use a |-construct. Furthermore I would use a characterclass for the first part ... this leads to

    $f =~ s/\s([iaeouyE]):(?:\s|$)/ $1 /;

    Update: Oops, this was meant as a reply to busunsl not to iakobski ...

    Update 2: and bikeNomad discovered some left out paras ... thanks, fixed it

    -- Hofmator