Skip to content

Commit db4b485

Browse files
authored
Document tip of using regex flags, regex: (?i)apple (#844)
1 parent b61d599 commit db4b485

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

website/guide/rule-config/atomic-rule.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,17 @@ So some features are not available like arbitrary look-ahead and back references
161161

162162
You should almost always combine `regex` with other atomic rules to make sure the regular expression is applied to the correct AST node. Regex matching is quite expensive and cannot be optimized based on AST node kinds. While `kind` and `pattern` rules can be only applied to nodes with specific `kind_id` for optimized performance.
163163

164+
:::tip
165+
You can use [Rust‑style inline flags](https://docs.rs/regex/latest/regex/#grouping-and-flags), for example:
166+
167+
```yaml
168+
rule:
169+
regex: "(?i)apple"
170+
```
171+
172+
This matches Apple as well as apple or APPLE.
173+
:::
174+
164175
## `nthChild`
165176

166177
`nthChild` is a rule to find nodes based on their indexes in the parent node's children list. In other words, it selects nodes based on their position among all sibling nodes within a parent node. It is very helpful in finding nodes without children or nodes appearing in specific positions.

0 commit comments

Comments
 (0)