What is ?s here?

satishmlmlml at gmail.com satishmlmlml at gmail.com
Tue Nov 11 04:37:21 EST 2014


What does ?s do in the following piece of code?

import re, pprint
text = open('books.xml').read()
pattern = '(?s)isbn="(.*?)".*?<title>(.*?)</title>'
found = re.findall(pattern, text)
mapping = {isbn: title for (isbn, title) in found}
pprint.pprint(mapping)

Here is books.xml

<catalog>
       <book isbn="0-596-00128-2">
             <title>Python & XML</title>
             <date>December 2001</date>
             <author>Jones, Drake</author>
       </book>
</catalog>



More information about the Python-list mailing list