Hi -
This will 'strip' all but a-zA-Z0-9:
#!/usr/bin/perl
use strict;
use warnings;
my $STRING = "kjsh234Sd\nki";
$STRING =~ s/[^a-zA-Z0-9]//sg;
print "$STRING\n";
the ~ makes the character class negative, the s makes
the regex examine new lines, and g means global.
Aloha -> Beau.
-----Original Message-----
From: Miguel Angelo [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 18, 2002 2:31 AM
To: [EMAIL PROTECTED]
Subject: Hi all, question about caracter detection
Hi All,
Thankx for reading this.
I have a very newbie question...
i'm working on a CGI and i want only to permit some
caracters by the user...
imagine
my $STRING = "kjsh234Sd\nki";
# now i want to check if there is any invalid caracter
# in this case a-z ; A-Z and 0-9
there for /[a-zA-Z0-9]/ but i am unable to find a
valid command for that, the \n always passes, i
definity do not want to use execption on what o do not
allow, i want only to allow some caracters
invalidating all others...
here what i have tried
if ( $STRING =~ /[a-zA-Z0-9]/ ) { etc }
my $count = ( $STRING =~ tr /a-zA-Z0-9// );
all failed...
please help me :)
=====
*****************************************
* Miguel Angelo *
* E-mail: [EMAIL PROTECTED] *
* Domain: http://migas.mine.nu *
*****************************************
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]