The example in this article describes jquery's method of implementing a full string replacement. Share to everyone for your reference, specific as follows:
Unlike the C # String type Replace method, the replace of jquery can only replace the first matching content.
For example:
var str = "a<br/>b<br/>c<br/>";
var newstr = str. Replace ("<br/>", "");
alert (NEWSTR); Content for:ab<br/>c<br/>
To replace all occurrences, you can use regular expressions:
var str = "a<br/>b<br/>c<br/>";
Re = new RegExp ("<br/>", "G"); Defines the regular expression
//The first parameter is the content to be replaced, and the second parameter "G" represents the replacement of all (global).
var newstr = str. Replace (Re, ""); The first argument is a regular expression.
//This example replaces all occurrences with the second argument.
alert (NEWSTR);//content: ABC
PS: Here again for you to provide 2 very convenient regular expression tools for your reference to use:
JavaScript Regular expression online test tool:
Http://tools.jb51.net/regex/javascript
Regular expression online generation tool:
Http://tools.jb51.net/regex/create_reg
More about jquery related content to view the site topics: "jquery string Operation Tips Summary", "jquery Operation XML Skills Summary", "JQuery Extended Skills Summary", "jquery selector usage Summary" and "jquery common Plug-ins and Usage summary"
I hope this article will help you with the jquery program design.