Describes how to use the JS Regular Expression replace and the jsreplace
Before talking about the advanced application of replace, let's sort out several important knowledge points in JS regular expressions to help you review your basic knowledge,
Detailed description of the string Regular Expression replace method in js, stringreplace
The replace method is a complex method in javascript involving regular expressions. It should be a string object method strictly. It only involves more regular
This article describes the JS String function String. replace (). For more information, see. Replace (one or more) substrings matching a given regular expression
String. replace (regexp, replacement)
Parameters:
Regexp: RegExp object or string
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:
The replace () method is used to replace other characters with some characters in a string, or to replace a substring that matches a regular expression.The replace () method has two parameters, the first parameter is a regular expression, and the
Linux shell string operation detailed (length, read, replace, intercept, connect, compare, delete, position) 1. Linux Shell intercepts the first 8 bits of a character variableThere are several ways to implement this:
Expr substr "$a" 1 8
Js replace (a, B) replace all the specified characters in the string, jsreplace
As follows:
Var str = 'abcadeacf '; var str1 = str. replace ('A', 'O'); alert (str1); // print the result: obcadeacfvar str2 = str. replace (/a/g, 'O'); alert (str2); /
I. type conversion
1. Convert to string
ECMAScript's Boolean values, numbers, and string values are interesting because they are pseudo objects, which means they actually have attributes and methods.For example:Js CodeVar sColor = "blue ";Alert
Record a mistake made in a development.
Requirement: Use JS to replace some substrings in the string with the specified new string .
Implementation ideas: The impression of JS string substitution has a replace method, the replace
String-related operations are often involved in the shell batch process. There are a lot of command statements, such as: awk,sed can do string various operations. In fact, the shell built a series of operating symbols, you can achieve similar
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.