10
1
Your task is to write a RegEx that matches everything inside strings.
A string is defined as everything surrounded by (but not including) two unescaped "
.
A "
can be escaped by \
, which can also be escaped again.
Testcases
string: ab\c"defg\\\"hi"jkl"mn\\\\"opqrst""
matches: ^^^^^^^^^^ ^^^^^^ ^ (the empty string)
Scoring
Shortest solution wins.
Specs
- Please specify the flavour used.
- The input will have balanced
"
. - There will be no
\
that immediately precedes a string-beginning-delimiter. For example, you would not need to handleabc\"def"
1Will there be
\
before a string? For exampleabc\"def"
. – jimmy23013 – 2016-05-20T10:29:05.827Should it match each string in one group? For example, could I write something that has two matches in
abc"de"
, one isd
and the other ise
? – jimmy23013 – 2016-05-20T10:43:53.373It is allowed . – Leaky Nun – 2016-05-20T10:44:29.947
Will there be empty strings? – Martin Ender – 2016-05-20T10:45:46.280
Yes, there will be empty strings. – Leaky Nun – 2016-05-20T10:48:37.420