[BASH] Keep only certain characters

Hi,
My google fu has failed me on this one

Im writing a bash script that can parse a xml document using xpath and then creates a php page, too add to my wordpress blog

however sometimes the returned string is invalid for php, or atleast in the function im using on the php script

so im trying to find a way to only keep certain characters in the string
like a-z A-Z spaces, periods, and commas

thanks

---------- Post updated at 07:11 PM ---------- Previous update was at 06:44 PM ----------

ok so after some more google i have found

sed 's/[^0-9]*//g'

this will remove all characters from a string except numbers,
how would i go about adding a-z A-Z space, periods and commas to this?

***edit***

Got it

sed 's/[^0-9a-zA-Z, .?]*//g'

this will make lots of scripts much easier now

"tr -d" is even more robust and fast at taking out anything but nulls.

"cat -vt" is very robust, turning out of range characters, everything but linefeed, into visible glyphs and characters tr or sed can handle. Here, 'all256' generates 0x00 through 0xff but no final line feed:

Prompt$ all256 | cat -vt
^@^A^B^C^D^E^F^G^H^I
^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-
M-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\M-^]M-^^M-^_M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[M-\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?Prompt$