Paul wrote:
> 
> --- "John W. Krahn" <[EMAIL PROTECTED]> wrote:

Why are you replying to me instead of the OP?  :-)

> > How can y give s sbstition order of the kind
> > @string=~s/nonalfanum//g;
> 
> Assuming @string was intended to be an array of values to scrub....
> otherwise, use $string.
> 
> > in these two cases?
> > 1-wich will search and replace with "" (empty char) all nunnumeric
> > or nonalphabetic chars?
> 
> Again, assuming @string was intended to be an array of values to scrub,
> 
>   y/[A-Za-z0-9]/[A-Za-z0-9]/d for @string;
> 
> This replaces alphas and digits with themselves, and deletes everything
> else; it does so for each item in @string iteratively.

It also replaces the '[' and ']' characters with themselves and doesn't
delete them.  The tr/// and y/// operators do not use regular
expression's character classes like m// and s/// do.  A simpler method
is to use the /c (complement) option to delete characters NOT in the
list.

    y/A-Za-z0-9//cd for @string;


> > 2-wich will search and replace with "" (empty char) all nunnumeric
> > or nonalphabetic chars with the exception of "-","_","@","." ?
> >
> 
> Same trick, different pattern. Just add the additional chars, but watch
> the minus....put it at the end so it isn't part of a range like a-z.
> 
>   y/[a-zA-Z0-9_@.-]/[a-zA-Z0-9_@.-]/ for @string;

    y/a-zA-Z0-9_@.-//cd for @string;



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to