PHP超强的模板替换函数
$string = ‘ajas{q111}ashdfkhask{w222}askdfhak{e333}aksjdfha{e333}kdfhkashdfkjashdfjkhasdkfjhaskjdfhaskdhfaskjdfhasjkdfhksdhbcdef’;
$pattern = ‘/\{([a-z|A-Z|_][a-z|A-Z|0-9|_]+?)\}/e’;
$q111 = ‘11111′;
$w222 = ‘2222′;
$e333 = ‘3333′;
$e333 = ‘4444′;
echo preg_replace($pattern, ‘${‘ . ‘\\1′ . ‘}’, $string);
Written by gegewan on 一月 22nd, 2010 with
1 comment.
Read more articles on 谈天说地.
- [+] Digg: Feature this article
- [+] Del.icio.us: Bookmark this article
- [+] Furl: Bookmark this article
#1. 四月 30th, 2010, at 11:11 上午.
这个正则表达式不错,收藏了