PDA

View Full Version : preg for XML


homerUK
10-02-2007, 05:01 PM
Hey - I need some help with (I think it's the right thing to use) PREG_replace.

I am exporting data to XML and it's having a nightmare with some characters in the text. I'd like to have a statement saying allow only alphabet, numbers and a few symbols eg

A-Z a-z 0-9 £$€%,&-'."

as the allowed characters. ANYTHING else would get dropped.

I searched on the net for some tutorials, but I've never been able to get my head around it!!

Argyle
10-02-2007, 05:59 PM
$new_string = ereg_replace(”[^A-Za-z0-9£$€%,&-]”, “”, $string_to_be_stripped);

or similar.