Language being used: PHP
Lets say I have an expression like this:
Ayala NOT ("Ayala Station" OR "Ayala Branch" OR "Joey Ayala")
And I want to extract the following words:
- Ayala
- Ayala Station
- Ayala Branch and
- Joey Ayala
I want to retrieve all phrases enclosed in double quotation mark " " and stand-alone words like the Ayala in the example above, but failed with experiments
Tried multiple regex
1st attempt:
"([^"]+)"
- I'm aware that this regex is the correct one for getting words/phrases inside double quotation mark
2nd attempt:
~\w+(?:-\w+)*~
- this regex will get all words from a given expression or string
3rd attempt:
Combining the 2 attempts above
"([^"]+)"|~\w+(?:-\w+)*~
- I was able to produce my use cases for my desired output but with these 2 combined, the Ayala word isn't being extracted
Example playground regex101
4th attempt:
Tried using "([^"]+)"|\S+
but it is including the special characters
Am I missing something with the regex?