In the previous reverse lookup in regular expressions, the RegExp object is used in JavaScript to implement the string substitution function of a regular expression reverse lookup, which is:
Program purpose to remove the domain name var str in the image path = ' '; var reg1 =/(/
This usage is applicable when there is only one URL in the string, but if the string contains more than one domain name, for example:
var str = ' NetEase home <a href= "http://www.163.com" > Links </a> ';
After the program is run, the content that is removed is the second domain name http://www.163.com. This is why.
A careful look at the regular expression will show that after using "(/
The difference with greed is one more question mark "?", greed ". *", not greedy ". *?" var reg1 =/(/
The solution to the problem is simple, but it also shows an important problem in peacetime work: Inadequate program testing.