Learn about javascript replace character in string, we have the largest and most updated javascript replace character in string information on alibabacloud.com
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.
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.
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:
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.
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.
Regular expressions are long-standing, and the Find-and-replace feature is very powerful, but templates are difficult to remember. The 2 methods of the match (), replace () of the string object in JavaScript use a regular expression template. When
EXEC () retrieves the specified value in the string, returns a value that is found, and returns null if no match is found: The main regexp pattern matching method is exec (), similar to the match method for the string object described in the
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.