Charles K. Clarkson wrote:
>
> Rob Dixon <[EMAIL PROTECTED]> wrote:
> :
> : > I tried all these substitutions. Unfortunately,
> : > they also destroy words in the string like can't,
> : > couldn't, what's, it's, and a multitude of others.
> : > Anyone with any solutions?
> :
> : Hi.
> :
> : A totally different solution:
> :
> : $_ = q(This is a character d g string test. What's more is
> : it's a winner and shouldn't fail.);
> : print join ' ', grep { not /^[a-z]$/i } split;
> :
> : **OUTPUT
> :
> : This is character string test. What's more is it's winner
> : and shouldn't fail.
>
> Hmmm. I wonder:
>
> $_ = q|It's a winner and shouldn't fail. Unless someone were prone to
> separating sentences with two spaces.|;
> print join ' ', grep { not /^[a-z]$/i } split;
Even in the simple case of single spacing, removing just the solitary
alpha characters results in a string with intervals of two or more
spaces, which is unlikely to be what is wanted.
This sort of detail depends on what the OP wants. How, for instance,
should a string like
$_ = q(This is a character d g string test.)
be handled?
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>