views:

328

answers:

1

How can I write a regular definition in (f)lex for quoted strings from AT&T language?

Example of string that come to my mind:

  • "abc"
  • "a\"bc"
  • "abc\"
  • "abc\""

Later edit:

  • "abc" "def" should be matched as two strings
  • "ab\"c" "def" should be matched as two strings
  • "abc\" "def" should be matched as two strings

The definition \"[^\"]\" is not working because it will match "abc" "def" as one string.

A: 

could you be more specific as to what strings you are trying to match? Strings that start and end with "? What do you mean by AT&T language?

Brian Schroth
Victor Hurdugaci
I am asking what are you actually trying to match here? Give an example of strings that the regular expression should match, and strings that the regular expression should not match. You have not been specific enough for it to be possible to answer this question.
Brian Schroth
Should match the four examples in the first post, each as a one match. I'll add some in 2 minutes
Victor Hurdugaci
so if I'm reading this correctly, your goal is to parse through one large block of text that contains multiple quoted strings? Like this might be your input:"abc" "def" "ghi" "gfderth" "dgsdfgsdfher" "sdff\"sdg" "zsfsdf"and your goal is to parse that out into 8 separate strings?will there ever be extra data between the strings, or are you guaranteed that the input will just be quoted strings with nothing in between? Like, would this be a possible input?"abc" sadfgnwunf "asdfjw" asdfenuf "sdfhe"
Brian Schroth
Actually I want 7 separated string for the input you provided. It will happen just as in C++: if you have "\n\" asga\"" this is parsed as a single string.
Victor Hurdugaci