Link to home
Create AccountLog in
Avatar of XK8ER
XK8ERFlag for United States of America

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..
<?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;
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of XK8ER

ASKER

that works nicely..