0

Quiz:

Validate a line in quotes. Return one (and only one) backreference with the text. ie: quoted text from "quoted text". Note: a \ escapes any char, so \" is a valid escape.

I know it's a common question and already been answered lots of times, but the problem is that no answer fits the correct for this quiz.

I started from simple (empty quotes are valid, should return null value in the backreference):

(?<=\s|^)"(.*?[^\\])?"(?=\s|$)

It shouldn't match "text"with quote". Only escaped quotes are allowed inside the main (opening and closing) quotes. You could use [^"].

Tried with backreferencing

((?<![\\])['"])((?:.(?!(?<![\\])\1))*.?)\1

You're using more than 1 group. Please only allow your pattern to set one backreference.

Alex Smoke
  • 619
  • 1
  • 8
  • 18

1 Answers1

0

This one was accepted by quiz

^"([^"\\]*(?:\\.[^"\\]*)*)"$
Alex Smoke
  • 619
  • 1
  • 8
  • 18