Re: String Replacement
| From: | Cynic | Date: | Mon, 15 Jan 2001 13:57:50 +0000 |
| Subject: | Re: String Replacement | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-5024@lists.php.net to get a copy of this message | ||
this one is really easy:
$ret = preg_replace( '/(?!boy)s/' , 'girl' , $text ) ;
At 12:34 15.1. 2001, adam wrote the following:
--------------------------------------------------------------
>Toby Butzon <php-lists@imawebdesigner.com> said:
>
>> lol...
>>
>> Ok, so you want to replace ONLY the word "boy" with the word "girl"...
>> you
>> don't want to touch "boys".
>>
>> Perhaps str_replace("boy ", "girl ", $myStr) would do the trick?
>>
>No, I thought of that - if the word is up against a fullstop or comma (or
>something else), that won't work. A regular expression will need to be used,
>and since I'm no good at them I can't make a suggestion. Sorry. :)
>
>adam
>
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
>For additional commands, e-mail: php-windows-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz