Source for file regex_replace.php

Documentation is available at regex_replace.php

  1. <?php
  2.  
  3. /**
  4.  * Replaces the search string by the replace string using regular expressions
  5.  * <pre>
  6.  *  * value : the string to search into
  7.  *  * search : the string to search for, must be a complete regular expression including delimiters
  8.  *  * replace : the string to use as a replacement, must be a complete regular expression including delimiters
  9.  * </pre>
  10.  * This software is provided 'as-is', without any express or implied warranty.
  11.  * In no event will the authors be held liable for any damages arising from the use of this software.
  12.  *
  13.  * This file is released under the LGPL
  14.  * "GNU Lesser General Public License"
  15.  * More information can be found here:
  16.  * {@link http://www.gnu.org/copyleft/lesser.html}
  17.  *
  18.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  19.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  20.  * @license    http://www.gnu.org/copyleft/lesser.html  GNU Lesser General Public License
  21.  * @link       http://dwoo.org/
  22.  * @version    0.9.1
  23.  * @date       2008-05-30
  24.  * @package    Dwoo
  25.  */
  26. function Dwoo_Plugin_regex_replace(Dwoo $dwoo$value$search$replace)
  27. {
  28.     // Credits for this to Monte Ohrt who made smarty's regex_replace modifier
  29.     if (($pos strpos($search"\0")) !== false{
  30.         $search substr($search0$pos);
  31.     }
  32.  
  33.     if (preg_match('#([a-z\s]+)$#i'$search$m&& strpos($m[0]'e'!== false{
  34.         $search substr($search0-strlen($m[0])) str_replace('e'''$m[0]);
  35.     }
  36.  
  37.     return preg_replace($search$replace$value);
  38. }

Documentation generated on Sat, 28 Jun 2008 01:38:33 +0200 by phpDocumentor 1.4.0