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
Copy code The code is as follows: <select> ...
In requireJS, there is a property called baseURL....
1. Function Mainly used to preserve component sta...
Uninstall the installed version on Ubuntu: sudo a...
Table of contents Install Dependencies Configurat...
MySQL replication table detailed explanation If w...
Introduction: When I looked at interview question...
Table of contents 1. Prerequisites 1.1 Supported ...
Table of contents 1. The default focus is on the ...
Event bubbling, event capturing, and event delega...
Table of contents 1. Demo Project 1.1 Interface P...
1. Introduction table_cache is a very important M...
Table of contents 1. Run workflow 2. Basic comman...
Preface When using the Deepin user interface, it ...
Table of contents 1. Get the first link first 2. ...