VID-1778 Script to remove categories with same names as video from file ...

...pages
Wow, PHP has a function for everything!  Since you've deftly taken care of $titleName with preg_quote, why not add in the rest of the category wiki text, call this $escapedCategoryTag and save yourself some escaping below on line 61?