Sandeep Deshpande wrote:
> Dear All,
> I am trying to pass list of acceptable characters in a string and then warn
> user about un-acceptable characters in the said string. My sample script
> goes as follows
> CASE 1:-
> ----------------------------------------------------
> my $filebuf = "ABCD123{}\[\]`";
> if ($filebuf =~ s/([^A-z\d])/<check>$1<\/check>/g)
> #if ($filebuf =~ s/(\W)/<check>$1<\/check>/g)
> {
> print $filebuf;
> }
> ----------------------------------------------------
> Now the output is
> Output 1:- ABCD123<check>{</check><check>}</check>[]`
>
> CASE 2:-
> If I comment if ($filebuf =~ s/([^A-z\d])/<check>$1<\/check>/gs) and
> un-comment if ($filebuf =~ s/(\W)/<check>$1<\/check>/gs), then I get
> following output
>
> i.e.
> ----------------------------------------------------
> my $filebuf = "ABCD123{}\[\]`";
> #if ($filebuf =~ s/([^A-z\d])/<check>$1<\/check>/g)
> if ($filebuf =~ s/(\W)/<check>$1<\/check>/g)
> {
> print $filebuf;
> }
> ----------------------------------------------------
>
> Output 2:-
> ABCD123<check>{</check><check>}</check><check>[</check><check>]</check><chec
> k>`</check>
>
> My question is
> Why the CASE 1 is unable to capture characters '[' , ']' , '`' ?
Your RE [^A-z\d] includes [ and ] along with \ ^ _ and `.
Try: [^A-Za-z\d]
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs