How to replace the specified position with replace () in js
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.