2012-04-03 21 views
0

当前,这是我有的preg_replace字符串。用正则表达式中的另一个字符替换字符PHP

$mtg_post['post_content'] = preg_replace("[^\\x20-\\x7e]", "",$ability); 

这是$ ability中包含的数据示例。

At the beginning of your upkeep, put a doom counter on Armageddon Clock.£At the 
beginning of your draw step, Armageddon Clock deals damage equal to the number 
of doom counters on it to each player.£{4}: Remove a doom counter from Armageddon 
Clock. Any player may activate this ability but only during any upkeep step. 

我想用2xreturn或新段落来替换£字符吗?在正则表达式,所以行看起来像这样,但不太确定如何实现这一点。

At the beginning of your upkeep, put a doom counter on Armageddon Clock. 

At the beginning of your draw step, Armageddon Clock deals damage equal 
to the number of doom counters on it to each player. 

{4}: Remove a doom counter from Armageddon Clock. Any player may activate 
    this ability but only during any upkeep step. 

回答

3

无需这里正则表达式,只需使用str_replace()

$out = str_replace("£", "\n\n", $in); 
+0

这将删除已在他们£整个线。 – 2012-04-03 22:56:49

+0

不适合我,也不会有意义。这里是一个演示:http://codepad.org/oho8zhgi – Cal 2012-04-03 23:02:21

+0

是的,我甚至手动把文本作为变量,并删除整条线。这里是全码的链接。 http://codepad.org/DupoYKzY – 2012-04-03 23:14:27