Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Replace Smart Quotes with javascript

Posted on 2004-08-09
Last Modified: 2009-02-13
I'm trying to write a validation script that takes the information in the "Description" field and replaces any "smart quotes" with a standard single apostrophe.  The tool is used by those that typically save paragraphs from Microsoft Word and these "funky" apostrophies are causing the application to crash.  Any thoughts?

here's my current code:

strDescription = String( theForm.Description.value )
_re = /’/gi;
strDescription = strDescription.replace( _re, "'" );
Question by:peerlesslv
LVL 36

Accepted Solution

Zyloch earned 125 total points
ID: 11756523

For single quotes, have this:

strDescription = String(theForm.Descript.value)
_re = /(?:\u2018|\u2019)/gi;
strDescription = strDescription.replace(_re, "'");


Author Comment

ID: 11756652
Perfect.  Thank you much Zyloch.


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question