Skip to content

Commit f38cffd

Browse files
committed
docs(cloudflare): prefer raw strings for regex patterns
- Document raw-string (r"...") guidance for regex literals - Clarify that (?i) controls case-insensitivity (not string form) - Link Cloudflare docs for string values and regex
1 parent b1d39c7 commit f38cffd

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

cloud-platforms/references/cloudflare.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@
55
- Never use `CloudFlare` anywhere (code/documentation). If found, fix to `Cloudflare`
66
- For Cloudflare, do not use the word `Domain`. Always use `Zone`. If any docs mention “Cloudflare Domain”, fix to “Cloudflare Zone”
77

8+
## Rules language regex strings (raw vs quoted)
9+
10+
Cloudflare expressions support string values as either quoted strings (`"..."`) or raw strings (`r"..."`).
11+
For regex patterns, prefer raw strings to reduce escaping mistakes (Cloudflare recommends this for regular expressions).
12+
13+
- **Quoted string**: backslashes are parsed by the string literal first, then by the regex engine - easy to under/over-escape
14+
- **Raw string**: fewer escape surprises, easier to review
15+
16+
> [!NOTE]
17+
> Case-insensitivity is separate. Use `(?i)` inside the regex (raw vs quoted does not control case sensitivity).
18+
>
19+
> Docs: `https://developers.cloudflare.com/ruleset-engine/rules-language/values/` (String values and regular expressions)
20+
21+
Example (raw regex + anchors):
22+
23+
```text
24+
(http.host matches r"(?i)^citizen-dev[0-9]+\.sbx\.apps\.acme\.com\.?$" and ip.src in $firm_egress_ips)
25+
```
26+
827
## Workers
928

1029
### Basic Worker

0 commit comments

Comments
 (0)