2012-04-03 18 views
0

derzeit ist dies die Preg_replace-Zeichenfolge, die ich habe.Ersetzen Sie Zeichen durch ein anderes Zeichen in Regex PHP

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

Dies ist ein Beispiel für die in $ fähigkeit enthaltenen Daten.

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. 

Ich möchte das £ -Zeichen durch 2xreturn oder neuen Absatz ersetzen? in Regex wird die Zeile so aussehen, aber nicht ganz sicher, wie dies zu implementieren ist.

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. 

Antwort

3

Keine Notwendigkeit für eine regexp hier, benutzen Sie einfach str_replace():

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

Dies löscht die gesamten Zeilen, die in ihnen £ haben. –

+0

Nicht für mich, noch würde das einen Sinn ergeben. Hier ist eine Demo: http://codepad.org/oho8zhgi – Cal

+0

Ja ich manuell sogar den Text als die Variable und es entfernt die gesamte Zeile. Hier ist der Link zum Fullcode. http://codepad.org/DupoYKzY –

Verwandte Themen