Convert HTML Entities

Source: Internet
Author: User

Converts characters in a string,,, & < > " (double quotation marks), and (single quotation marks) to their corresponding HTML entities.

If you get stuck, remember to open a big recruit read-search-ask. Try programming with others, writing your own code.

Here are some resources that are helpful to you:

    • Regexp
    • HTML Entities
function Convert (str) {//&colon;&rpar;  varo = {    "&":"&amp;",    "<":"&lt;",    ">":"&gt;",    '"':"&quot;",    "'":"&apos;"  }; varReg =/[&<>"']/g;  returnstr.replace (Reg,function (m) {returnO[m]; });} Convert ("Dolce & Gabbana");

This question immediately reminds me

DNA Pairing

The method of using the object is really simple.

function pair (str) {varn \ {    'G':'C',    'C':'G',    'A':'T',    'T':'A',  }; returnStr.split ("'). Map (function (cur) {return[cur, o[cur]]; }); Pair ("A");

Convert HTML Entities

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.