Reputation: 127
It's late here in europe and I can't get that regex running :-( I want to match all text, that is not surrounded by quotes.
INPUT: Oh yeah this;input;'with quotes';can;'be very';tricky;'believe me';boy
It's really easy to match all text surrounded by quotes.
But what I want is the opposite. Also the match should be splitted by ; so that I get the following matches:
Any ideas before I get mad?
thx in advance!
Upvotes: 2
Views: 1640
Reputation: 16958
I think you can use a trick like this:
'[^;]*'(?=;|$)|([^;]+)(?=;|$)
Explanation:
'[^;]*'(?=;|$) => finding words between `'` and ended with `;` or end of text, but not group it
| => or
([^;]+)(?=;|$) => finding other words ended with `;` or end of text, but grouped
now you can use $1
to catch what you want.
Upvotes: 2
Reputation: 10458
you can use the regex
(?<=;|^)[^;'][^;]*[^;'](?=;|$)
see the regex101 demo, regex storm demo
Upvotes: 1