✨
Formatters & Regex Cheatsheet
JSON formatting rules, YAML gotchas, regex syntax flags and quick reference.
JSON Syntax Rules
| Rule | Valid | Invalid |
|---|---|---|
| Keys must be quoted | "name": "Alice" | name: "Alice" |
| Strings use double quotes | "hello" | 'hello' |
| No trailing commas | {"a":1,"b":2} | {"a":1,"b":2,} |
| No comments | {"x":1} | {"x":1} // comment |
| Numbers are unquoted | {"n":42} | {"n":"42"} (if numeric) |
| Boolean lowercase | {"ok":true} | {"ok":True} |
| Null is lowercase | {"v":null} | {"v":None} |
YAML Gotchas
| Gotcha | Notes |
|---|---|
| Norway problem | "NO" → false (old YAML 1.1). Use "no" in quotes. |
| Tabs not allowed | YAML indentation must use spaces only, never tabs. |
| Colon in values | Quote values containing colons: "http://example.com" |
| Multiline strings | Use | for literal block, > for folded block. |
| Null values | null, ~, or empty value are all equivalent to null. |
| Merge keys | "<<: *anchor" merges a YAML anchor into the current mapping. |
Regex Flags
| Flag | Name | Effect |
|---|---|---|
| g | Global | Find all matches, not just the first |
| i | Case insensitive | A matches a |
| m | Multiline | ^ and $ match start/end of each line |
| s | Dot all | . matches newline characters too |
| u | Unicode | Enable Unicode code point escapes (\u{...}) |
| d | Indices | Include start/end indices for each match (ES2022) |