Re: Really simple regex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Rory Browne <rory.browne@xxxxxxxxx> :
> preg_replace("/x+/", "x", $string); should do it. Having that said,
> regex generally comes back and bites me in the ass, so...........

That one won't -- that's spot on.

> On 6/8/05, Dotan Cohen <dotancohen@xxxxxxxxx> wrote:
> > Now, I know that this is easy, but I am embarassed to say that I can't
> > find a regex tutorial that will show me how to match any occurances of
> > x and replace them with one x:
> > 
> > xxxxx > x
> > xx > x
> > x > x
> > 
> > $string="I have xxxxxxxx apples!";
> > $string=preg_replace("-regex here-","x", $string);
> > print "$string";
> > 
> > I have x apples!
> > 
> > I searched marc because I know that I've seen this, but I don't know
> > on what keywords to search. I know that php uses perl-compatable
> > regular expressions, but in no tutorial did I find this. I know that *
> > matches any amount of occurances of a string, but formulating it to do
> > it in the middle of a string of text I could not get.


-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:matthew@xxxxxxxxxx         | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux