Gossamer Forum
Home : General : Perl Programming :

string manipulation question

Quote Reply
string manipulation question
i want to remove all punctuation from a string, but keep spaces. is this the best way to do it?

Code:
$fixlink = $EVENT->{details}->{'title'};
$fixlink =~ s/[\s]/qqqqq/g;
$fixlink =~ s/[\W]//g;
$fixlink =~ s/qqqqq/ /g;
Quote Reply
Re: [delicia] string manipulation question In reply to
Sure , that should work. You could do it by specifying all the charachters you wanna exclude, i.e:

Code:
$var =~ s/[\t -\.]//sg;

....but that means you have to specifically enter each character you wanna filter out.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates