29 October 2014
Search and replace using regular expression in PHP using preg_replace function. It is very powerful way to search and replace. I suggest using some online regular expression tool to test out your patterns.
Source code viewer
- * In regular expressions parentheses are used to determinate subpatterns.
- * Subpattern results are put to variables such as $1, $2, etc.
- echo preg_replace('/<picture(.*?)href=/', '<img$1src=', $str);Programming Language: PHP