Automatically exported from code.google.com/p/planningalerts
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

36 lignes
900 B

  1. <?php
  2. /**
  3. * Smarty plugin
  4. * @package Smarty
  5. * @subpackage plugins
  6. */
  7. /**
  8. * Smarty regex_replace modifier plugin
  9. *
  10. * Type: modifier<br>
  11. * Name: regex_replace<br>
  12. * Purpose: regular expression search/replace
  13. * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
  14. * regex_replace (Smarty online manual)
  15. * @author Monte Ohrt <monte at ohrt dot com>
  16. * @param string
  17. * @param string|array
  18. * @param string|array
  19. * @return string
  20. */
  21. function smarty_modifier_regex_replace($string, $search, $replace)
  22. {
  23. if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
  24. /* remove eval-modifier from $search */
  25. $search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
  26. }
  27. return preg_replace($search, $replace, $string);
  28. }
  29. /* vim: set expandtab: */
  30. ?>