Search Regex Plugin
Search Regex adds a powerful set of search and replace functions to WordPress. These go beyond the standard searching capabilities, and allow you to search and replace almost any data stored on your site. In addition to simple searches you have the full power of PHP's regular expressions at your disposal.
The driving force behind this plugin is to aid in website migration and upgrading. If you've ever done either of these then you know the pain of having to go back through all your data, changing URL paths and fixing things. With this plugin you can reduce this work to a search and replace pattern and the job is finished in seconds.
Why would you want this? The primary reason for the plugin was to aid in relocating directories. It's a real pain to manually go through every post and change image directory names. With this plugin all that was required was a simple search and replace pattern, and the job was finished in a few seconds.
Features include:
- Simple search and replace
- Advanced regular expression search and replaces, including back references and capture groups
- Search previews with inline replacing
- Perform searches in post & page content, excerpt, titles, URL, and meta-data, as well as comment content and author data
- Full support for WordPress roles. You can only search and replace in posts you have access to
- Fully localized
Get the Flash Player to see this movie.
Version History
- 1.4.8 - Update base library. Fix issue with regex not being selected
- 1.4.7 - Fix for 2.6 versions
- 1.4.6 - Added tag & sniplet searching. Make work in Safari
- 1.4.5 - Add search regex capabilities ('search_regex_read' and 'search_regex_write'). Fix meta values
- 1.4.4 - Fix escaping issue, allowing search limit and direction
Installation
Installation is just like any WordPress plugin:
- Download search-regex.zip
- Unzip
- Upload directory to
/wp-content/pluginson your server - Activate the plugin
- Use
Search Regexfrom theManage/Search Regexmenu
You can find full details of installing a plugin on the plugin installation page.
Usage
Searches can be performed from the Search Regex submenu, contained within the main Manage menu of the administration interface. Once there you will be presented with the following interface:
The search and replace patterns are, as you would expect, where you enter what you want to search for and what you want to replace it with. Several options exist to refine the searching capabilities, which will be explained later. You can also chose the data source.
When you have entered your patterns you need to press one of the search buttons:
- Search - Just do a search and show the results
- Replace - Perform a search and replace, but only show the results. The database is not changed.
- Replace & Save - As Replace, but the replacements are saved back into the database.
It should be noted that while you can enter any search pattern in a simple search, you must adhere to regular expression syntax when the regular expression mode is enabled. The plugin will detect any regular expression errors and warn you.
If you wish to remove a search pattern (i.e. search for 'cheese' and delete the any occurrences) then you can leave the replacement pattern empty.
Search Options
The following options modify the search:
- Regex - Enable regular expressions. Note that the search pattern can now only contained properly escaped characters. The @ character is used as a delimiter and also needs escaping.
- Case-less - Case insensitive search
- Multi-line - Enables multi-line mode (see PHP's pattern modifiers page)
- Dot-all - Enables the dot-all mode (see PHP's pattern modifiers page)
Results
Search results as presented as a list of found occurrences. Each result is shown in context with the surrounding data and, if enabled, the replacement context is also shown.
Depending upon the data source you have options to view, edit, or replace the data. Additionally, if you double-click on the highlighted search or replace patterns then an inline edit box will appear allowing you to directly edit the data.
Examples
The simplest case is changing paths:
/wp-images/
to
/images/
A more complicated regular expression version to only move PNG images:
/wp-images/(.*?).png
to
/images/png/$1.png
Warning
You should always use the Search & Replace preview before saving to the database. I will accept no responsibility for any damage caused to your data. If you are in any doubt then backup your database first.
Support
Please direct all support questions to the Search Regex support forum. Any support questions left on this page may not be answered.
Bugs & New Features
A full list of all bugs can be found in the Search Regex issue tracker.
| Date | Current requested features |
|---|---|
| 29 Mar 2008 | Add checkboxes to replace search-results |
| 06 Apr 2008 | Replace with newline |
A full list of all requested features can be found in the Search Regex feature tracker.






Comments (page 1 of 10)
Jul 26, 2006 3:01 am
Sorry Alan, that was a stupid typo on my behalf. Try 1.2
Jul 17, 2006 2:18 pm
fails saying set_timeout_limit isn't defined. i tried editing it to set_time_limit, but I still end up with the same failure to load page, or a blank result

Ta tho
Jul 17, 2006 2:10 pm
i'll have a look see, thanks
Jul 12, 2006 9:46 pm
Alan, I've made the plugin use an unlimited timeout value which, depending on your host, may solve the problem.
Jul 5, 2006 1:28 pm
Just to let you know, i'm currently hacking it by chopping up the database by ID range with
SELECT ID, post_content, post_title FROM wp_posts where ID>0 and ID < 5000 order by ID
and that's working out for now. but obv the timeout would be better to over-ride
Jul 5, 2006 1:19 pm
I can use this on the small comments database, but on the posts/pages, it's possibly timing out. in safari i get:
"Safari can’t open the page “.../wordpress/wp-admin/edit.php?page=search-regex.php” because it could not load any data from this location"
anyway to over-ride this or is there a limitation in the plugin architecture
Jun 27, 2006 4:38 pm
Great, I like simple solutions!
Jun 27, 2006 9:05 am
Oops. Was running 1.5. Just upgraded to 2.0 and it works now.
Jun 26, 2006 5:22 pm
What version of WordPress are you running? What other plugins do you have?
Jun 25, 2006 11:14 pm
Hi,
I'm getting this error when I activate the plugin...
Fatal error: Call to undefined function: is_admin() in /var/www/html/blog/wp-content/plugins/search-regex/search-regex.php on line 11
Any ideas?
StudioGlyphic
Leave a comment