I have started to learn automata theory and languages. I am new to regular expressions.
As a use case in real world, I would like to construct a regular expression to accept a c-style string: enclosed by double quotes, allows escape sequences (\" to escape a double quote, \ escape a backslash, \n escape a new line...) and allows all characters in between, and pretty much everything that the standard identifies as a string literal.
I don't have a specific language that the regex is to be used in, for I'm not going to use this in a program. I just want to know the theory behind constructing the regex, one step at a time. For example, Initially, how to account for the enclosing quotes ? then how to allow arbitrary sequences of characters between the quotes ? and then how to account for escaping ?
I don't have a regex tester. I just need the construction idea.
Strings that are to be accepted are, for example,
"hello world!"
"hi!\n"
"000022lkjads\t{"
"\0Hello World"
The following would be rejected
"hello
for there is no enclosing double quotes
"Hello World""
for it does not escape the quote