The proposed expression \"(\\.)*\" That you proposed corresponds to strings consisting of \ characters, alternating with any characters of the type:
"\z\x\p\r"
So this regular expression will not match the string, for example:
"hello"
The string "hello" will match the regular expression \".*\" , But also matches the string """" or "\" , both of which are invalid.
To get rid of these invalid matches, we can use \"[^\\"]*\" , but now it will not match a string like "\a\a\a" , which is a valid string.
As we saw, \"(\\.)*\" Matches this line, so all we need to do is combine these two to get \"(\\.|[^\\"])*\" .
source share