Re: regular expression to extract from the middle of a string

From: Date: Fri, 14 Jul 2006 18:27:38 +0000
Subject: Re: regular expression to extract from the middle of a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-239475@lists.php.net to get a copy of this message
On 7/14/06, Steve Turnbull <steve.turnbull@yhgfl.net> wrote:
I have a string similar to the following; cn=emailadmin,ou=services,dc=domain,dc=net I want to extract whatever falls between the 'cn=' and the following comma - in this case 'emailadmin'.
$pattern= "/[^=]+=([^,]+)/"; preg_match($pattern, $string, $matches); print_r($matches); Voila! (Untested for now, I'm pretty drunk so sorry if it ain't workin out like you want to) -- Kim Christensen

« previous php.general (#239475) next »