Hi,
This is for a mediawiki site, we will use a regex search and replace function to execute the command,
it is an extension that automatically runs the string on the pages, so not directly the whole database
The database is mysql, but the regex I will run will not actually be run on the database as such,
mediawiki allows me to run the search and replace on only the articles and titles directly through an extension, so I wont run this on a dump or in mysql itself,
Here is the description from the author of the extension
The set of regular expressions allowed is basically a small subset of the PHP and MySQL regular-expression sets (it has only been tested with MySQL - whether it works on other database systems is unknown). The characters that one can use in the search string are "( ) . * + ? [ ] |", and within the replacement string one can use values like $1, $2 etc. This section will not give a tutorial on using regular expressions (the Wikipedia article is a good place to start for that, as is this page on MySQL regexps), but here is the basic example listed in the inline explanation:
Search string: a(.)c
Replacement string: ac$1
This would look for pages containing the letter 'a', the letter 'c', and any text in between (signified by the "."). It would then put that middle text after the 'a' and 'c' - the "$1" in the replacement string refers to the first element of the search string contained within parentheses (in this case, there's only one).
Well, I suppose this depends on which subset of the regular expressions the extension writer decided to use. The ones used by PHP vary, and the ones used by MySQL are POSIX compliant. So we'll try a POSIX compliant version:
Search : \(([0-9]{4})\)|([0-9]{4})
Replace: ($1)
But it's difficult to say if it will work correctly or not.
In unix,to find a string in a file and replace it with another string, you can use the below procedure
"
Open the file with 'vi' editor.
The last line can be specified as a dollar sign ($). To search and replace from the current line through the last line use the command:
:.,$s/up/right/ <'up' is the term to be found and 'right' is the term to be replaced.>