Pattern Replacing
| From: | Sterling | Date: | Thu, 29 Mar 2001 20:07:41 +0000 |
| Subject: | Pattern Replacing | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-46143@lists.php.net to get a copy of this message | ||
H-
Well here's a pattern replace issue which I've been working on without
success hence the post. 8^)
I have a variable that has stuff in it (tree, bird, nest, )(yes there is
a trailing space)
What I'd like to do is strip off the last ', ' and replace it with a
single space so that I have
(tree, bird, nest )
I thought I had it with a simple substr_replace but it only returned my
replace character.
I thought that ereg_replace would work but got infinitly lost with the
[]\s(.) stuff.
If I was in perl I'd do something like (s/,.$/ /ig). I think. Never
fully grasped the pattern stuff anyway. 8^/
But anywhoo... if anyone has any ideas send them along. Any help would
be greatly appreciated.
Thanks.
-Sterling