[Courses] [Perl] Part 8: The "s///" Operator
Bowen, Tricia
tbowen at CapitalThinking.com
Fri Nov 7 18:00:14 EST 2003
try running this on the command-line:
perl -pi.bak -e 's/\W//g' test.txt
\W is equivalent to anything other than a word character ([^a-zA-Z0-9_]).
test.txt is a sample file that contains your crazy characters.
--tricia
-----Original Message-----
From: Rui Fernandes [mailto:ruifernandes at tvtel.pt]
Sent: Thursday, November 06, 2003 3:15 PM
To: courses at linuxchix.org
Subject: [Courses] [Perl] Part 8: The "s///" Operator
Importance: High
Dear Sir,
I've got a problem with a substitution in Perl. I have a string ( let's supose $word) that can have values like the followings - it's impredictable:
asd3$( .ophG
wordº çhtn mnfbgd
@word_8 klMNBVFR 12
I want to extract only the character A to Z , a to z and 0 to 1 from the strings so I could have:
asd3ophG
word çhtn mnfbgd
word 8 kIMNBVFR 12
How can I do this if I don't know the number of letters in the string?
Please answer as soon as possible - It's very urgent.
Best regards,
Rui Fernandes
_______________________________________________
Courses mailing list
Courses at linuxchix.org
http://mailman.linuxchix.org/mailman/listinfo/courses
More information about the Courses
mailing list