I'm trying to extract the substring in-between two double quotes if present but I am only able to get the substring with the last double quote.
If the string has no double quotes, extract the substring
TEST STRINGS
"松嶋友里奈/ウェルキッズフォト" <[email protected]>
SuperBacker Team <[email protected]>
Medium Daily Digest <[email protected]>
"Tory @ Flippa" <[email protected]>
CocaCola <[email protected]>
My regex for python: "(?!\")(.*?)(?!\")(?=\s\<)"
ACTUAL RESULT
松嶋友里奈/ウェルキッズフォト**"** --> FAILED because of the double quote at the end
SuperBacker Team --> PASS
Medium Daily Digest --> PASS
Tory @ Flippa**"** --> FAILED because of the double quote at the end
CocaCola --> PASS
Why does my pattern include the double quote at the end but not at the beginning?
CodePudding user response:
((?<=^)(?=[^\"])|(?<=\")).*[^\"](?=\"?\s\<)
((?<=^)(?=[^\"])|(?<=\"))
either beginning of string - not followed by " ((?<=^)(?=[^\"])
) or starting after " ((?<=\")
).*[^\"]
anything that does not end in a double quote(?=\"?\s\<)
followed by optionally a double quote and then<