View Single Post
Old 09-26-2014, 07:22 AM   #8
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,682
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Keeth View Post
Quote:
Originally Posted by Doitsu View Post
Find:<h4 id="sigil_toc_id_(\d+)">(.*?)</h4>
Replace:<h3 id="sigil_toc_id_\1">\2 \1</h3>
That looks very interesting. Would you mind explaining what each bit is actually doing? I am not familiar with the regex codes...
I's a fairly simple expression and I'm pretty sure that the Regex gurus who read the posts in this forum will come up with a much more efficient one.

The search expression (\d+) searches for one or more numbers. (Putting it in brackets allows it to recycle the match as \1 in the replace statement.)
The search expression (.*?) searches for any sequence of characters. Since it's the second bracketed expression, whatever matches it, can be referred to as \2 in the replace statement.

There are lots of Regex tutorials that explain all of this in much more detail, and there's also a Sigil Regex subforum.
Doitsu is offline   Reply With Quote