用正则表达式PHP中的另一个字符替换字符

时间:2012-04-03 22:43:21

标签: php regex wordpress expression

目前,这是我的preg_replace字符串。

$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.

1 个答案:

答案 0 :(得分:3)

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

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