Compile often used regexps only once outside of the loop. This commit improves the performance of large wiki pages with many, many references.