Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to replace the specified position with replace () in js

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "how to replace the designated location with replace () in js", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to replace the specified location with replace () in js" article.

Usage

Str.replace (regexp/substr, text/function)

instructions

The first parameter is the query condition, which can be a string or a regular expression.

The second parameter is the replacement rule, which can be a string or a function of a string to replace the string to which the query condition matches.

Returns a new string that is obtained after replacing the first match or all matches of regexp with replacement.

Use an example

Replace the specified position with replace () in js: concatenate the string to be replaced before and after with the string to be replaced

Var strobj = 'ABCDEFGABEF';// wants to replace the EF in position 4 and 5 without moving the EF endstr=replacepos (strobj,4,5,'344'); console.log (endstr); / / ABCD344GABED; function replacepos (text,start,stop,replacetext) {mystr = text.substring (0meme Strom 1) + replacetext+text.substring (stop+1); return mystr } the above is about the content of this article on "how to replace a specified location with replace () in js". I believe everyone has a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report