问题
I have to remove a lot of font-family: declarations from my website, they are hundreds and I have replaced most of them with the same line, only commented (ex: /* font-family: "Segoe UI","Helvetica","Arial"; */).
Now, if I could only search for the un-commented ones to find the few that are left. My first atempt clearly demonstrates I do not fully understand regular expressions:
^(?!(?:/*)).*\s*."font-family:"."*"
The syntax is Boost (but only a subpart of it, as the replacement is PCRE-style).
回答1:
You have almost done it yourself, I just fixed your tempered greedy token:
^(?:(?!/\*).)*\s*font-family:.*
See regex demo
Regex explanation:
^- start of line (in S&R in SublimeText)(?:(?!/\*).)*- a tempered greedy token matching 0 or more characters other than a newline up to the first/*(to force a.to match newlines, add(?s)before^)\s*- zero or more whitespace symbolsfont-family:- a literal sequence offont-family:.*- 0 or more characters other than newline
来源:https://stackoverflow.com/questions/34354806/regular-expression-search-in-sublime-for-all-font-family-not-preceded-by-an-ope