Re: Getting part of string matched with regular expressions

From: Date: Mon, 28 Jan 2008 12:40:22 +0000
Subject: Re: Getting part of string matched with regular expressions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-268194@lists.php.net to get a copy of this message
Teck wrote: > I'm trying to find a way to get part of a string where the part is > matched with regular expressions. > > So, for example, if I have a string: > > a2b3cd5ef6ghi7232jklmn > > I need to grab "12b3cd5" using regular expressions and store the part > in a variable. Assuming you meant to grab '2b3cd5': $matches=preg_match( '/2b3cd5/',$text,$match ); $var=$match[0]; /Per Jessen, Zürich

« previous php.general (#268194) next »