preg_replace

PHP 4, PHP 5, PHP 7, PHP 8
preg_replace - Perform a regular expression search and replace

Example #1 Using backreferences followed by numeric literals

Result: April1,2003
PHP Version:

Example #2 Using indexed arrays with preg_replace

Result: The bear black slow jumps over the lazy dog.
PHP Version:

Example #3 Replacing several values

Result: $startDate = 5/27/1999
PHP Version:

Example #4 Strip whitespace

PHP Version:

Example #5 Using the <span class='function-parameter'>count</span> parameter

Result: xp***to 3
PHP Version:


Example #6 of preg_replace

PHP Version:


Function preg_replace:

Regular Expressions (Perl-Compatible) Functions

Most used PHP functions