1. Match any number in front of REM in a string similar to 12rem or 12.32rem
var xx = "Font-size:12rem;width:12.33rem;height:200rem;";
Xx.match (/(\d+) + (? =rem\b) | ( \d+\.) \d+ (=rem\b)/g);
Results: ["12", "12.33", "200"]
Description: A regular expression with/begins with a/g ending that represents a global match, \d represents a number, (\d+) indicates that the number repeats one or more times, and (? =rem\b) represents the front portion of a word (except REM) that matches a rem ending (\d+\.) The \d+ matches the integer digits with the decimal digits as any number of decimals.
2. Replace color: #fff或者color: #FFF, or color:white; for color: #000;
var yy = "color: #fff; Width:20rem;height:33rem;color: #FFF; overflow:hidden;color:white;";
Yy.replace (/color: #fff |color: #FFF |color:white/g, "color: #000");
Result: "COLOR: #000; Width:20rem;height:33rem;color: #000; Overflow:hidden;color: #000;"
3. Matches the preceding number part of a string that ends in. xhtml
var zz = "E:/android/projects/xxt/epub/1.xhtml";
var tt = "e:/android/projects/xxt/epub/12.xhtml";
Zz.match (/\d+ (=.xhtml$)/g) Result: ["1"]
Tt.match (/\d+ (=.xhtml$)/g) Result: ["12"]
Description:. xhtml$ represents a string that ends in XHTML, (? =.xhtml$) that matches the preceding part of the word (except. xhtml) at the end of XHTML.
JS Regular expression