Also take a look at the at the very good regex intro in the Calibre forum -
https://www.mobileread.com/forums/sho...d.php?t=118569 which also links to the more extensive, although python specific, regex details at
http://docs.python.org/library/re.html
The use of (?s) tells the expression to let '.' match everything including newlines - by default '.' matches everything except newlines. Since ? is used for different things in regex it can be a bit confusing (here with (? it means the next character(s) are flags for special handling and there are lots of them, ? after a normal character means 0 or 1 occurrences, and ? after * or + or ? means non-greedy/minimal matching). No wonder regex is confusing
I have a feeling there will be more and more questions about regex. Maybe we need a sticky at the top (even to link to the Calibre post?) or a quick help guide link in Sigil itself with examples. I guess the trouble is that everyone has their own way of using regex, and any examples can quickly become overwhelming.