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.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
- 1.4.3 - Allow searching in trackbacks and pings
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 9 of 9)
Jun 22, 2008 2:51 pm
Manish, you only see the regex options when you click the regex button. The save option only appears when you double-click an entry.
Search Regex is now fully WP 2.5 compatible
Jun 22, 2008 1:18 pm
Ahhh, here we go. Ticking regex box then the thing must be surrounded with @
e.g.
@foo.bar/[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]@
Jun 22, 2008 1:12 pm
I'd really appreciate a few 'worked examples'.
E.g. I would like to change links of http://foo.bar/2008/06/05/postslug into http://foo.bar/postslug
The first test, foo.bar/[0-9]* yields an error: 'Invalid regular expression: Delimiter must not be alphanumeric or backslash'
which doesn't help me much...
Pings & Trackbacks
1wordpress.com, alabase2.com, alligatorcat.com, andersdenken20.de, blog.nanowings.de, cooperation.gensys-net.eu, d.teknoseyir.com, dltj.org, facemakers.stu.ru, imagensmix.com, ivangelion.tw, ldl.blog.dark-souls.ru, lifehacker.biz, mindman.1gb.ru, newsoft.com.ua, obezblog.com, plasticdreams.org, prowordpress.org, shakin.ru, sparanoid.com, tecnoblog.net, triumphalroman.net, ultra.boy.jp, webloger.ru, wiki-futureforexwin.info, wpmania.ru, wpstation.com, ayiva.com, blogpiloten.de, ccicenter.org, clarkburbidge.com, desperatelyseekingwp.com, freefullsoftwares.com, isaythat.com, lostnode.com, luxeseo.com, makadco.com, midasoracle.org, mr-foto.net, perraco.com, psicofxp.com, readers-edition.de, rehlaonline.com, seopost.ru, smashingmagazine.com, socialdailynews.com, themelab.com, tmthai.com, tommyholiday.ch, vasif.net, venukb.com, wordpresscn.com, wordpressplugin.org, zhangzhang.net, xuyiyang.com
Leave a comment