What I want to do is to extract all values between single or double quotation marks.
Let's say I have the following values.
"Alice's Adventures in Wonderland 1"
"Alice's 'Adventures' in Wonderland 1"
"Alice's "Adventures" in Wonderland 1"
"Alice's Adventures \nin Wonderland 1"
'Alice's Adventures in Wonderland 1'
'Alice's "Adventures" in Wonderland 1'
'Alice's 'Adventures' in Wonderland 1'
'Alice's Adventures \tin Wonderland 1'
And the desired outputs are:
Alice's Adventures in Wonderland 1
Alice's 'Adventures' in Wonderland 1
Alice's "Adventures" in Wonderland 1
Alice's Adventures \nin Wonderland 1
Alice's Adventures in Wonderland 1
Alice's "Adventures" in Wonderland 1
Alice's 'Adventures' in Wonderland 1
Alice's Adventures \tin Wonderland 1
How should I write the regex (using one regex expression for extracting all the desired values at once) to get the whole texts enclosed in the first and last quotation marks ?
p.s. I want to use re.search(r"...", text) method
r'"(.*)"'should just work. - kwkt(?:'(.*)'|\"(.*)\")works for me. But note that this won't work with the multiline flag, or if there are multiple examples on the same line - M Z