XK8ER
asked on
clean up text with preg replace
hello,
I have a little code that its working perfectly fine but I would like to add a little feature so it an also remove bird.org
right now it removes cats.net maybe because it doesn't have a comma right next to it..
I have a little code that its working perfectly fine but I would like to add a little feature so it an also remove bird.org
right now it removes cats.net maybe because it doesn't have a comma right next to it..
<?php
$str = 'text here google.com text here
text here http://cows.net/search/query?123 text here
text here cats.net text here
text here bird.org, text here';
$result = preg_replace('/ (?:cows\.com|cats\.net|bird\.org) /', ' ', $str);
echo $result;
?>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER