"John W. Krahn" schreef:
> Dr.Ruud:
>> You might actually be looking for this:
>>
>> (my $newstring = $oldstring) =~ tr/0-9A-Za-z/ /cds;
>>
>> which replaces runs of non-alphanumeric characters with a single
>> space.
>
> No it doesn't:
Oops, thanks for the correction. I was meant to be without
Didn't see this one before I hit 'Send'.
-Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED]
Sent: Friday, August 25, 2006 6:28 PM
To: Perl Beginners
Subject: Re: Using a regular expression to remove all except
certaincharacters.
John W. Krahn wrote:
O
Comments below.
-Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED]
Sent: Friday, August 25, 2006 6:25 PM
To: Perl Beginners
Subject: Re: Using a regular expression to remove all except
certaincharacters.
Dr.Ruud wrote:
>>
>> You might actually be look
John W. Krahn wrote:
> Dr.Ruud wrote:
>>Jim Schueckler schreef:
>>
>>>I need to remove all characters from a string except 'a'..'z',
>>>'A'..'Z', and '0'..'9'.
>>>
>>>Could somebody please tell me the magicWords for:
>>> $newstring = magicWords($oldstring);???
>>>
>>>I am absolutely new to Per
Dr.Ruud wrote:
> Jim Schueckler schreef:
>
>>I need to remove all characters from a string except 'a'..'z',
>>'A'..'Z', and '0'..'9'.
>>
>>Could somebody please tell me the magicWords for:
>> $newstring = magicWords($oldstring);???
>>
>>I am absolutely new to Perl and regular expressions, so
Jim Schueckler schreef:
> I need to remove all characters from a string except 'a'..'z',
> 'A'..'Z', and '0'..'9'.
>
> Could somebody please tell me the magicWords for:
>$newstring = magicWords($oldstring);???
>
> I am absolutely new to Perl and regular expressions, so please don't
> assum
How about this?
#Substitute any character that is not one of the ones in
#our character class with nothing
$newstring =~ s/[^a-zA-Z0-9]//g;
Note the '^' at the start of the character class. In a character class
it means "not", as in "not these characters". If you see it at the
start