Regular expression to split on whitespace but ignore a double-quoted string
1 answer
You can use PCRE verbs (*SKIP)(*FAIL)
to tell the regular expression to skip certain parts of the expression. So:
".*?"(*SKIP)(*FAIL)|\s+
will skip double quotes. Here's a demo of regex101:
https://regex101.com/r/eBP67C/1/
You can read more about this here http://www.rexegg.com/regex-best-trick.html#pcrevariation .
+3
source to share