From 4f3bce79bfb5851cef9e7bc655c91bb3093cc401 Mon Sep 17 00:00:00 2001 From: donncha Date: Tue, 12 Jul 2005 11:27:54 +0000 Subject: Initial Import git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- .../smarty-plugins/modifier.regex_replace.php | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 wp-inst/wp-content/smarty-plugins/modifier.regex_replace.php (limited to 'wp-inst/wp-content/smarty-plugins/modifier.regex_replace.php') diff --git a/wp-inst/wp-content/smarty-plugins/modifier.regex_replace.php b/wp-inst/wp-content/smarty-plugins/modifier.regex_replace.php new file mode 100644 index 0000000..7eee497 --- /dev/null +++ b/wp-inst/wp-content/smarty-plugins/modifier.regex_replace.php @@ -0,0 +1,33 @@ + + * Name: regex_replace
+ * Purpose: regular epxression search/replace + * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php + * regex_replace (Smarty online manual) + * @param string + * @param string|array + * @param string|array + * @return string + */ +function smarty_modifier_regex_replace($string, $search, $replace) +{ + if (preg_match('!\W(\w+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { + /* remove eval-modifier from $search */ + $search = substr($search, 0, -strlen($match[1])) . str_replace('e', '', $match[1]); + } + return preg_replace($search, $replace, $string); +} + +/* vim: set expandtab: */ + +?> -- cgit