Some of my MediaWiki web pages has the <pre>
HTML tag and I need to replace generally all <pre>
tags in the <code>
tags.
How to find all web pages with a certain HTML tag?
Take a backup first.
Using phpMyAdmin (or similar) you can run an SQL query using REPLACE to update the tags in place. The 'text' table holds the pages for MediaWiki in the 'old_text' field.
First run:
select 'old_text' from 'text' where 'old_text' like '%pre>%';
to see what in the old_text database will be changed and make sure no extra code is matching that tag fragment.
Then run:
update 'text' set 'old_text' = replace('old_text', 'pre>', 'code>');
to update all the instances of pre>
(which should match the <pre>
and </pre>
tags only) with code>
. If you want to avoid the possibility of matching weird stuff that's not the actual tags then do two updates, one for <pre>
and one for </pre>
.
Caution, untested code.
You could easily export the table containing your pages content in phpmyadmin.
For the export, select the "Update" method and only data.
Open it in your text editor, search and replace <pre>
and </pre>
tags with your new tag.
Then Import your updated data in phpmyadmin.
Make a backup of your database on first place