challenge: Converts the characters &, <, >, " (double quote), and ' (single quote) in a string to their corresponding HTML entities. If you get stuck, use Read-Search-Ask. Try exchanging programming ideas with others, but write your own code. For example:
Answer:
function convert(str) { var list = { "&":"&", "<":"<", ">":">", '"':"", "'":"'", }; for(var key in list){ str=str.replace(new RegExp(key,"g"),list[key]); } return str; } convert("Dolce & Gabbana"); Running results:
Online test: HTML symbol to entity algorithm challenge | w3cschool Summarize This is the end of this article about the challenge of converting HTML symbols to entities. For more relevant content about converting HTML symbols to entities, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: How to create a MySQL master-slave database using Docker on MacOS
>>: Detailed example of locating and optimizing slow query sql in MySQL
Quick solution for forgetting MYSQL database pass...
<br />I have summarized the annotation writi...
background: Because the server deployed the flask...
Using the knowledge of CSS variables, I will dire...
Preface Introduction Lombok is a handy tool, just...
environment Server: centos7 Client: window Deploy...
The first parameter passing method is dynamic rou...
Table of contents 1. Use the withRouter component...
1. AIDE AIDE (Advanced Intrusion Detection Enviro...
1. In IE, if relative positioning is used, that is...
Preface: This article is based on the experience ...
Prelude We all know that nginx is an excellent re...
<br />Original: http://www.alistapart.com/ar...
Table of contents How to flatten an array 1. Usin...
Table of contents Overview Require URL of the app...