Share functions to completely replace JavaScript strings. js string functions

Source: Internet
Author: User

Share functions to completely replace JavaScript strings. js string functions

In the past few days, the function of Completely replacing JavaScript strings has been used. If you do not need to say anything, simply copy the code and you can:

Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "UTF-8"/>
<Title> </title>
<Script type = "application/javascript">
Function testStr (){
Var temp = document. getElementById ("content"). value;
Var newContent = temp. replace (/"/g ,'\'');
Alert (newContent );
}
</Script>
</Head>
<Body>
<Textarea id = "content"> </textarea>
<Input type = "button" value = "work" onclick = "testStr ();"/>
</Body>
</Html>

The above Code provides the function of replacing quotation marks, And/g indicates that all quotation marks are replaced. Other requirements can be changed. I will take a note here, hoping to help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.