Re: Regular expression

From: Date: Fri, 03 Feb 2006 23:34:16 +0000
Subject: Re: Regular expression
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-229862@lists.php.net to get a copy of this message
$last_comma = strrpos($string, ","); $string = substr($string, 0, $last_comma) . ' and ' . substr($string, $last_comma); I probably have a one-off error in there somewhere, or swapped the order of args in strrpos, but you get the idea. http://php.net/strrpos On Mon, January 30, 2006 8:09 am, Barry wrote: > Simple reg help please > > i want to match the last "," in "a,b,c,d" and replace it with " and > " > > i tried ereg_replace(",([a-zA-z])*$"," and ",$string); > > but i forgot how to add the "d" which is also matched now back to the > " and " > > Can you give any good reg_exp sites where to learn it? > Its long ago since i used reg exp and i lost the hang of it... :( > > btw. any sites that have reg_exp that works witht PHP would be fine. > i know http://www.regular-expressions.info/tutorial.html > But that examples dont work with preg_match and ereg. > > Thanks ^_^ > > -- > Smileys rule (cX.x)C --o(^_^o) > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#229862) next »