0

I need to match "String""" as two strings.

I'm using this for my school project (Lexer implementation) and I'm having a problem with situation when I get something like "Something""" being matched as one string Something""

Thank you guys in advance!

Nikola Milutinovic
  • 731
  • 1
  • 8
  • 23

1 Answers1

0

How about

"(.*?)"

where *? is the lazy 0 or more token.

skynet
  • 9,898
  • 5
  • 43
  • 52
  • Actually it gives me an error because it does not match **""** – Nikola Milutinovic Oct 27 '13 at 01:58
  • Works for me. How are you using it? I am using `Pattern.compile("\"(.*?)\"")` and then getting the matcher `pattern.matcher("\"Something\"\"\"")`. – skynet Oct 27 '13 at 02:04
  • Thank you, I tried this too and it did work with every online tester I found but in Java flex file it just didn't do what it is supposed to. I found a way to solve this: ` \" {yybegin(STRING); string.setLength(0); } { \" {yybegin(YYINITIAL); return new_symbol(sym.STRING, string.toString()); } {StringCharacter} + { string.append( yytext() ); } }` – Nikola Milutinovic Oct 27 '13 at 02:38