You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regular expression flags in procedural cosmetic filters #3372
Currently, it looks like the procedural cosmetic filter that can take in regex are not able to take in other trailing flags such as /g/i/m or even within the regex like /(?i)example/.
Can support for these be added? They can improve efficiency of rules that can use them and reduce filter length/number of some filters.
The syntax is the same a literal javascript regex flags:
example.com##body:has-text(/PRIOR/i)
Only two flags are supported: i and m (support for g is pointless).
I partially checked with some filter lists known to use procedural selectors and I could not find any ambiguity. If ever someone needs to lookup for a string literal like /ad/im, the solution is to use a regular expression to work around flag parsing: /\/ad\/im/.
String literal. I don't want special syntax such as wildcards -- that is why regex literals are supported, to take care of when a string literal is not enough.
So am I to understand that the g flag isn't needed because uBO already will find all matches and not just stop after the first match? (please correct me if I'm wrong)
Activity
gorhill commentedon Dec 31, 2017
The syntax is the same a literal javascript regex flags:
Only two flags are supported:
iandm(support forgis pointless).I partially checked with some filter lists known to use procedural selectors and I could not find any ambiguity. If ever someone needs to lookup for a string literal like
/ad/im, the solution is to use a regular expression to work around flag parsing:/\/ad\/im/.jspenguin2017 commentedon Dec 31, 2017
Would
/ad/im*be parsed as string literal or still RegExp?gorhill commentedon Dec 31, 2017
String literal. I don't want special syntax such as wildcards -- that is why regex literals are supported, to take care of when a string literal is not enough.
jspenguin2017 commentedon Dec 31, 2017
So the proper solution to make
/ad/ima string literal would be add a trailing wildcard?Kusresa commentedon Dec 31, 2017
Just curious, why is it pointless?
jspenguin2017 commentedon Dec 31, 2017
If it matches it matches, doesn't matter how many times.
Kusresa commentedon Dec 31, 2017
So am I to understand that the
gflag isn't needed because uBO already will find all matches and not just stop after the first match? (please correct me if I'm wrong)jspenguin2017 commentedon Dec 31, 2017
You only need to match once for the filter to trigger.
fix gorhill#3372