XJS: How to remove special characters in email in xml string

I'm making a call to a web service where it returns the email with special characters ‡
It does not always return ‡, sometimes it's others and I won't know.

I have the following xml string where I want to clean up the email

var  strResponse = '<Body><PaxRS><ItineraryRef ID="XBHGGE"/><TravelRS><Travel><CustomerInfo><PersonName><Email>‡JOHNDOE@AOL.COM‡1.1</Email></PersonName></CustomerInfo></Travel></TravelRS></PaxRS></Body>';

I want to be able to clean up the email of any special characters that exist, how can I do this in xjs if i don't know the exact special characters that the web service would be returning?

I tried doing this with xslt and though it would strip out the special characters, within the actual platform I'm using it would not remove it, so I want to remove it via javascript instead.

Please advise.
Who is Participating?
zephyr_hex (Megan)DeveloperCommented:
You can achieve this by removing any non-ASCII characters.

strResponse.replace(/[^\x00-\x7F]/g, "");

Open in new window

Fiddle Demo: https://jsfiddle.net/zephyr_hex/tfz7deds/
badtz7229Author Commented:
thank you. that worked.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.