Reputation: 1
maybe the problems seems bathetic, but at the moment I have a real problem in extracting strings from quotes, but fulfilling certain criteria. These are
All my experiments failed. The best guess of mine was:
(?<=(?<!\\)").*?(?=(?<!\\)")
The problem of it is that if there are no quotes at all, the extracted string is empty.
Thanks a lot for the help
Best regards
cerebro
Upvotes: 0
Views: 129
Reputation: 786091
For the test cases written in your question following regex should work for you:
^([^"\n\\]*)(?:\\(")|"|)([^"\n\\]*)(?:\\(")|"|)(.*)$
You need to concatenate group # 1, 2, 3, 4, 5 to get your captured string.
Upvotes: 1