pattern | - is a string that is a perl compatible regular expression as documented at: http://us.php.net/manual/en/ref.pcre.php This expression passed to this function should have delimiters and can contain the standard perl modifiers after the ending delimiter. | |
replacement | - is the string to use as the replacement. This string may contain capture group references such as \1. You can also use $1 for these in a similar fashion as in PHP. | |
subject | -is the data to perform the match & replace on | |
limit | - optional number that is the maximum replacements to perform. Use -1 (or leave empty) for no limit. |
- string - the same as passed in if there were no matches
Yields:
+-----------------------------------------------------------------+ | PREG_REPLACE('/(.*?)(fox)/' , '$1dog' , 'the quick brown fox' ) | +-----------------------------------------------------------------+ | the quick brown dog | +-----------------------------------------------------------------+ *
SELECT PREG_REPLACE('/\s\s/+', ' ' , products.title FROM products;
Yields: The product names with all of the extra whitespace removed