2012-04-03 17 views
0

現在、これは私が持っているpreg_replace文字列です。regexの文字を他の文字に置き換えるPHP

$mtg_post['post_content'] = preg_replace("[^\\x20-\\x7e]", "",$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

これは、彼らに£ている行全体を削除します。 –

+0

私にとってではなく、それは意味をなさないでしょう。ここではデモです:http://codepad.org/oho8zhgi – Cal

+0

私は手動で変数としてテキストを入れて、それは全体の行を削除します。ここにフルコードへのリンクがあります。 http://codepad.org/DupoYKzY –

関連する問題