In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "javascript how to replace all the specified strings". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how javascript replaces all specified strings".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Javascript replace () method
The replace () method is used to replace some characters in a string with other characters, or to replace a substring that matches a regular expression.
Syntax format:
String.replace (searchvalue,newvalue)
Searchvalue: yes. A RegExp object that specifies the substring or the schema to replace.
Note that if the value is a string, it is treated as an immediate amount of text pattern to retrieve, rather than being first converted to a RegExp object.
Newvalue: required. A string value. Specifies the function that replaces the text or generates the alternate text.
The second parameter of the replace () method can use the function, which is called when the match occurs, the return value of the function is used as the replacement text, and the function can receive special characters prefixed with $to reference information about the matching text.
The special character convention string in the second parameter of the replace () method describes $1, $2,..., $99 text matching the 1st through 99th subexpression in the regular expression $& (dollar sign + hyphen) substring $'(dollar sign + switch skill key) matching regular expression $'(dollar sign + single quotation mark) text $'(dollar sign + single quotation mark) to the left of the matching substring $$represents the $string to the right of the matching string
Return value: a new string, obtained after replacing the first match or all matches of regexp with replacement.
Example: the replace () method replaces all strings
Var str= "hello"; var a=str.replace ("hello", "HI"); console.log (a)
Thank you for your reading, the above is the content of "how javascript replaces all the specified strings". After the study of this article, I believe you have a deeper understanding of how javascript replaces all the specified strings, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.