Discover javascript replace character, include the articles, news, trends, analysis and practical advice about javascript replace character on alibabacloud.com
Key two parts of the knowledge point
1. JavaScript replace () function usage
The following replace usage is reproduced from w3cschool:http://www.w3school.com.cn/jsref/jsref_replace.asp
Definitions and Usage
The replace () method replaces some
JavaScript has a very useful method replace (), which can be used to take advantage of the character specified by the alternative character set tu huan. Below is a good example, you can try to replace the specified character in a text input box.
This article mainly introduces how the JavaScript language supports the Unicode Character Set. For more information, see what I will share with you next month, and the support of the JavaScript language. The following is the lecture for this sharing.
Document directory
JavaScript indexOf () method
JavaScript substring () method
JavaScript split () method
JavaScript replace () method
JavaScript indexOf () method definition and usage
The indexOf () method returns the position of the first
String. Replace ()
Syntax:
String. Replace (Regexp, replacement)
Regexp: the regular expression of the replacement operation. If a string is input, it is processed as a normal character and only one replacement operation is performed. If it is
Document directory
Enter:
Because the replaceall () method is not provided in Javascript, it is not very comfortable to use. Next I will show you how to use the replace method to obtain columns with other effects, such as the replaceall effect.
In js, we can use replace () to replace the characters, numbers, or letters in the string, or replace () with regular expressions, below I will introduce some common methods of character replacement.
For example
The Code is as follows:
String. replace ()
Syntax:
Var strings = string. replace (regexp, replacement)
Regexp: the regular expression of the replacement operation. If a string is input, it is processed as a normal character and only one replacement operation is performed.
Use Javascript to replace Chinese characters/match Chinese characters/Chinese Character regular expressions. Today, I asked a question about the regular expression of js Chinese characters, so let's record it.
Use Javascript to replace Chinese
Definition and UsageThe replace () method is used to replace other characters with some characters in a string, or to replace a substring that matches a regular expression.Stringobject.replace (regexp/substr,replacement)
Parameters
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.