This time I will bring you the advanced replacement method of JavaScript regular expressions. The following is a case, follow the editor to take a look.
Ordinary regular replacement generally replaces the first matched value or all matched values replaces ,
For example:
"abc,abc,ab".replace(/a/,'1');
Result: "1bc,abc,ab";
##"abc,abc,ab".replace(/a/g ,'1');
Result: "1bc,1bc,1b"
Advanced point Replacement: Replace the third digit of the IP address with *.
192.168.33.12 becomes 192.168.*.12
##"192.168.33.12".replace (/(\d{1,3}).(\d{1,3}).(\d{1,3}).(\d{1,3})/,"$1.$2.*. $4")
The above is the detailed content of About advanced replacement of javascript regular expressions. For more information, please follow other related articles on the PHP Chinese website!