Pattern library / Strings & Text
Regex to Match JSON Property Names
Matches a JSON property name in double quotes. Useful for log parsing, schema validation, and extracting keys from JSON-like text.
How the pattern works
"— opening quote.[A-Za-z_]— key must start with letter or underscore.[A-Za-z0-9_]*— rest of key.- For keys with spaces or special chars, use
"[^"]*"instead.
Test it: match & no-match examples
Every row is loaded straight into the tester — click Try to see the match live:
| Input | Result | Why | |
|---|---|---|---|
"name" | Match | simple key | Try → |
"user_id" | Match | snake_case key | Try → |
"_private" | Match | leading underscore | Try → |
"123" | No match | starts with digit | Try → |
"has space" | No match | space not allowed | Try → |
name | No match | missing quotes | Try → |
Where to use it
JavaScript
const re = /^"[A-Za-z_][A-Za-z0-9_]*"$/;
re.test('"user_id"'); // true
Python
import re, json re.match(r'^"[A-Za-z_][A-Za-z0-9_]*"$', '"user_id"')
Common mistakes
Test this pattern on your own data
Paste it into the free tester with your real strings — nothing leaves your browser.
FAQ
Related patterns
For GA4-specific patterns, see the GA4 regex cheat sheet, the page path regex guide, the event filter regex guide, the GA4 regex match types, the custom channel grouping guide and RE2 vs PCRE. Browse the full regex pattern library.