Link to home
Start Free TrialLog in
Avatar of Vlearns
Vlearns

asked on

remove invalid characters from string

i have a string in perl which crashes the code because the system throws the folowing errors

must not contain the following characters [\\, /, *, ?, \", <, >, |,  , ,]]"

is it possible to write a regex in perl that strips these characters from the string?

thanks!
Avatar of ozo
ozo
Flag of United States of America image

s/[\\/*?"<>|,\]]//g;
Avatar of Vlearns
Vlearns

ASKER

s/[\\/*?"<>|,\]]//g; seems to fail,

does it need to be
s/[\\/*?"<>|,\/]]//g;

extra /before] ?
Avatar of Vlearns

ASKER

$search =~ s/[\\/*?"<>|,\/]]//g;

this fails too,
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial