SPUG: removing a special character

Miles Crawford mcrawfor at u.washington.edu
Tue Oct 3 13:35:42 PDT 2006



Crap!

How about this instead:

$foo = 'string\' with b at d `chars';

$foo =~ s/[^a-z0-9]//ig;

I forgot the 'g' - the first one only removed the first bad char.

You may also want to add a ' ' to the a-z0-9 bit to preserve spaces.

-miles




On Tue, 3 Oct 2006, Miles Crawford wrote:

>
>
> Luis,
>
> Try something like this:
>
>
> $foo = 'string\' with b at d `chars';
>
> $foo =~ s/[^a-z0-9]//i;
>
> But read http://perldoc.perl.org/perlre.html first ;)
>
> -miles
>
>
> On Tue, 3 Oct 2006, luis medrano wrote:
>
>> List,
>> 
>> I need to remove this character ' but I'm using linux if I copy paste
>> it will show something like this â. any idea how can I fix this or
>> how can I just remove everything except numbers and letters?
>> 
>> Thanks,
>> luis
>> _____________________________________________________________
>> Seattle Perl Users Group Mailing List
>>     POST TO: spug-list at pm.org
>> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>>    MEETINGS: 3rd Tuesdays
>>    WEB PAGE: http://seattleperl.org/
>


More information about the spug-list mailing list