Formatters & Regex Cheatsheet

JSON formatting rules, YAML gotchas, regex syntax flags and quick reference.

JSON Syntax Rules

RuleValidInvalid
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

GotchaNotes
Norway problem"NO" → false (old YAML 1.1). Use "no" in quotes.
Tabs not allowedYAML indentation must use spaces only, never tabs.
Colon in valuesQuote values containing colons: "http://example.com"
Multiline stringsUse | for literal block, > for folded block.
Null valuesnull, ~, or empty value are all equivalent to null.
Merge keys"<<: *anchor" merges a YAML anchor into the current mapping.

Regex Flags

FlagNameEffect
gGlobalFind all matches, not just the first
iCase insensitiveA matches a
mMultiline^ and $ match start/end of each line
sDot all. matches newline characters too
uUnicodeEnable Unicode code point escapes (\u{...})
dIndicesInclude start/end indices for each match (ES2022)
← All Cheatsheets