Pattern library / Strings & Text
Regex to Match Simple CSV Lines
Matches a CSV row where values have no commas, quotes, or newlines. For quoted CSV with embedded commas, use a proper CSV parser.
How the pattern works
[^,]+— one or more non-comma chars.(,[^,]+)*— comma + value, repeated.- This regex does NOT handle quoted fields with embedded commas — use a CSV parser for that.
- Add
\s*around commas if spaces are allowed.
Test it: match & no-match examples
Every row is loaded straight into the tester — click Try to see the match live:
| Input | Result | Why | |
|---|---|---|---|
a,b,c | Match | three values | Try → |
single | Match | one value | Try → |
a,,c | No match | empty value rejected | Try → |
a,b, | No match | trailing comma rejected | Try → |
Where to use it
JavaScript
const re = /^[^,]+(,[^,]+)*$/;
re.test('a,b,c'); // true
Python
import re, csv re.match(r'^[^,]+(,[^,]+)*$', 'a,b,c')
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.