Skip to content

Commit c444ec4

Browse files
authored
Merge pull request #714 from SelYui/feature/AG-35374
Add support for regular expressions in `$app` modifier
2 parents 4593b9d + 4f9e9cc commit c444ec4

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

docs/general/ad-filtering/create-own-filters.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,19 @@ This modifier lets you narrow the rule coverage down to a specific application (
425425

426426
For Mac, you can find out the bundle ID or the process name of the app by viewing the respective request details in the Filtering log.
427427

428+
**Syntax**
429+
430+
The modifier is a list of one or more expressions, each of which is matched against an application in a particular way depending on its type. These expressions are separated by the `|` symbol.
431+
432+
```text
433+
applications = ["~"] entry_0 ["|" ["~"] entry_1 ["|" ["~"]entry_2 ["|" ... ["|" ["~"]entry_N]]]]
434+
entry_i = ( regular_app / wildcard_app / regexp )
435+
```
436+
437+
- **`regular_app`** — a regular application name (`example.app`). It corresponds to the specified application and is matched lexicographically.
438+
- **`wildcard_app`** — an application name ending with a wildcard character `*`, such as `org.example.*` or `com.ad*`. It matches all applications whose names start with the specified prefix. Matching is done lexicographically.
439+
- **`regexp`** — a regular expression that starts and ends with `/`. It works the same way as the basic URL rules, but the characters `/`, `$`, `,`, and `|` must be escaped with `\`.
440+
428441
**Examples**
429442

430443
- `||baddomain.com^$app=org.example.app` — a rule to block requests that match the specified mask and are sent from the `org.example.app` Android app.
@@ -435,17 +448,32 @@ If you want the rule not to be applied to certain apps, start the app name with
435448
- `||baddomain.com^$app=~org.example.app` — a rule to block requests that match the specified mask and are sent from any app except for the `org.example.app`.
436449
- `||baddomain.com^$app=~org.example.app1|~org.example.app2` — same as above, but now two apps are excluded: `org.example.app1` and `org.example.app2`.
437450

451+
You can use wildcards in the `$app` modifier:
452+
453+
- `||baddomain.com^$app=org.example.*` — applies to all apps whose package names start with `org.example.`
454+
455+
You can use regular expressions in the `$app` modifier by enclosing them in forward slashes `/.../`. This allows for more flexible matching — for example, targeting a group of apps from the same publisher or matching complex patterns.
456+
457+
- `||baddomain.com^$app=/org\.example\.[a-z0-9_]+/` — applies to all apps whose package name starts with `org.example` (e.g. `org.example.app1`, `org.example.utility`, etc.).
458+
- `||baddomain.com^$app=/^org\.example\.app\$\|^org\.example\.[ab].*/` — applies to `org.example.app` and to any app whose package starts with `org.example.a` or `org.example.b`.
459+
460+
The `$app` modifier supports combining all three types of entries — plain names, wildcards, and regular expressions — within the same rule, but it does not allow combining negated and non-negated expressions together.
461+
462+
- `||example.com^$app=org.example.app|org.example.*|/org\.example\.[a-z]+/` — applies to `org.example.app`, all matching `org.example.*` and `org.example.[a-z]+` apps.
463+
438464
:::caution Restrictions
439465

440-
Apps in the modifier value cannot have a wildcard, e.g. `$app=com.*.music`.
441-
Rules with such modifier are considered invalid.
466+
- Apps in the modifier value cannot include a wildcard inside the string , e.g. `$app=com.*.music`.
467+
Use a regular expression instead: `$app=/com\..*\.music/`.
468+
- You cannot combine negated (`~`) and non-negated expressions in the same `$app` modifier — this would be ambiguous.
442469

443470
:::
444471

445472
:::info Compatibility
446473

447474
- Only AdGuard for Windows, Mac, Android are technically capable of using rules with `$app` modifier.
448475
- On Windows the process name is case-insensitive starting with AdGuard for Windows with [CoreLibs] v1.12 or later.
476+
- Support for regular expressions and for combining different types of entries (plain names, wildcards, and regular expressions) in the `$app` modifier is available starting from CoreLibs v1.19 or later.
449477

450478
:::
451479

@@ -1939,7 +1967,7 @@ In AdGuard for Windows, Mac and Android with [CoreLibs] v1.11 or later, JSONPath
19391967
{
19401968
"elems": [
19411969
{
1942-
"a": {"b": {"c": 123}},
1970+
"a": {"b": {"c": 123}}
19431971
},
19441972
{
19451973
"a": {"b": {"c": "abc"}}

0 commit comments

Comments
 (0)