Identifying duplicate quotes in string with regex

Viewed 21

I'm new to ER and I have the following exercise to solve:

In PL/I, a string is enclosed in double quotes. But if inside the string also has a quotation mark, it must be preceded by another quotation mark. So, the string

The quotation mark, ", should be typeset in italics

would be written in PL/I as

“The quotation mark, ““, should be typeset in italics”

Design an ER to recognize strings in PL/I. Assume that the strings contain only symbols defined in an alphabet Σ and that quotes are the only special case.

I can already capture the string in quotes with:

^["].*.["]$

But I can't write the conditional for "if the quotes exist, there must be a quote before"

I've searched a lot, but haven't found a solution yet. Any help is appreciated.

0 Answers
Related