Re: String Replacement
| From: | Daniel Beulshausen | Date: | Mon, 15 Jan 2001 14:15:18 +0000 |
| Subject: | Re: String Replacement | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-5025@lists.php.net to get a copy of this message | ||
At 14:57 15.01.2001 +0100, Cynic wrote:
this one is really easy: $ret = preg_replace( '/(?!boy)s/' , 'girl' , $text ) ;<?php $string = "boys, boy, fort boyard"; $string = preg_replace("/boy(?!\w)/", "girl", $string); print $string; ?> should be correct. daniel
At 12:34 15.1. 2001, adam wrote the following: -------------------------------------------------------------- Toby Butzon <php-lists@imawebdesigner.com> said:/*-- daniel beulshausen - daniel@php4win.de using php on windows? http://www.php4win.deNo, 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 -- 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.netlol... 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?