Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search and replacing with Javascript 1

Status
Not open for further replies.

droid99

Programmer
Jul 6, 2004
5
US
Hello,

I am a Perl programmer and have only used JavaScript minimally. I've been researching how to do simple search and replaces in JavaScript but can't find any good reference material. Basically, I want to know what the equivalent of this Perl statement would look like in JavaScript:

$html =~ s/\'/'/g;

I am trying to replace the single quote character with its corresponding html code.

Any help will be appreciated.
 
Code:
var newcode = oldcode.replace(/'/g, "'");

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top