I am trying to construct a regex to by used in a python program with the following constraints
Check is there is any substring within quotes with at least 3 words (separated by spaces). Below are some examples
"Hello word \"Foo bat baz kay \" exit"
This should return true since it contains the substring "Foo bar baz kay" with at least 3 words within the quote substring.
" Hello hello \" world \" exit"
should return false.
Based on some investigation I was able to divide the problem into two separate parts
Find a regex to get all substrings within quotes, so something like
re.findall(r'"(.*?)"', s)
Find a regex to get all string with more than one word
^\s*[A-Za-z0-9]+(?:\s+[A-Za-z0-9]+)\s$
I tried to put them together, but it doesn't yeild the expected result. Sorry I am new to regex so I am probably not doing this right. Here is the partial code. These ideas are compiled from the following posts RegEx: Grabbing values between quotation marks
Regex for one or more words separated by spaces
s = "Some string with quotes : \"Hello world example\" and another quote is \" hello world\" done"
print(re.findall(r'"(^\s*[A-Za-z0-9]+(?:\s+[A-Za-z0-9]+)*\s*$)"', s))
Please advise. Appreciate your help!