Re: regex : Extracting parts of a string :-???
| From: | Christian Reiniger | Date: | Sun, 11 Feb 2001 17:06:23 +0000 |
| Subject: | Re: regex : Extracting parts of a string :-??? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-39129@lists.php.net to get a copy of this message | ||
On Sunday 11 February 2001 17:21, akio wrote:
> $thestring = "\"Hello everyone\" bye";
>
> What I want to extract is: Hello everyone. Instead I get: bye.
> I use this command
>
> ereg("([^\"\"]*)$",$thestring,$regs)
>
> and echo $regs[1].
>
> How can I extract what's within double quotes?
Hmm, I only know the preg syntax. With that it's
preg_match ('/"([^"]*?)"/', $thestring, $matches);
$InQuotes = $matches [1];
--
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)
"use the source, luke." (obi-wan gnuobi)