Reputation: 1607
I'm new to regex and I'm currently running into an issue when matching multiple consecutive strings.
I want to match strings: "this is a string"
. I managed to do that.
However, I would also like to match multiple strings if they are concatenated or separated by only whitespace: "this""is a string"
, or "this" "is" "one string"
.
The problem I'm having is that if I try to do that I also match "this" as "a string"
(note the matched as
this should be two separate strings).
I'm using flexc++ so I cannot use more fancy regex stuff like lookahead.
Currently I defined a string as (i used multiple different definitions this one seems the simplest):
string \"(.*?)\"
and then try to match multiples using:
{string}[ \t]*{string}*
Upvotes: 1
Views: 762
Reputation: 5325
This should work \"[^\"]*\"([ \t]*\"[^\"]*\")*
Or if give a string definition:
string \"[^\"]*\"
concat_strings {string}([ \t]*{string})*
Upvotes: 2