I'm reading a response from a source which is an journal or an essay and I have the html response as a string like:
According to some, dreams express "profound aspects of personality" (Foulkes 184), though others disagree.
My goal is just to extract all of the quotes out of the given string and save each of them into a list. My approach was:
[match.start() for m in re.Matches(inputString, "\"([^\"]*)\""))]
Somehow it didn't work for me. Any helps on my regex here? Thanks a lot.
Another way to supply a double quote (") to an Excel formula is by using the CHAR function with the code number 34. The first two arguments of this MID formula raise no questions: A2 is the text string to search, and. SEARCH("""", A2) +1 is the starting number, i.e. the position of the first quote +1.
You can put a backslash character followed by a quote ( \" or \' ). This is called an escape sequence and Python will remove the backslash, and put just the quote in the string. Here is an example. The backslashes protect the quotes, but are not printed.
Question marks and exclamation marks go inside the quotation marks when they are part of the original quotation. For split quotations, it's also necessary to add a comma after the first part of the quotation and after the narrative element (just like you would with a declarative quotation).
Provided there are no nested quotes:
re.findall(r'"([^"]*)"', inputString)
Demo:
>>> import re
>>> inputString = 'According to some, dreams express "profound aspects of personality" (Foulkes 184), though others disagree.'
>>> re.findall(r'"([^"]*)"', inputString)
['profound aspects of personality']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With