Replace character with another character in regex PHP

Go To StackoverFlow.com

0

currently, this is the preg_replace string that I have.

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

This is an example of the data contained within $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.

I want to replace the £ character with 2xreturn or new paragraph? in regex so the line will look like this but not quite sure how to implement this.

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.
2012-04-03 22:43
by Justin Lucas


3

No need for a regexp here, just use str_replace():

$out = str_replace("£", "\n\n", $in);
2012-04-03 22:45
by Cal
This deletes the entire lines that have £ in them - Justin Lucas 2012-04-03 22:56
Not for me, nor would that make sense. Here's a demo: http://codepad.org/oho8zhg - Cal 2012-04-03 23:02
Yep I even manually put the text in as the variable and it removes the whole line. here's the link to the fullcode. http://codepad.org/DupoYKz - Justin Lucas 2012-04-03 23:14
Problem was since I was pulling from an XML file that was in utf8 I had to utf8_decode it first before replacing the string - Justin Lucas 2012-04-04 13:31
Ads