Re: [PHP] Re: Regex for extracting quoted strings

2011-03-07 Thread Shawn McKenzie
On 03/05/2011 04:38 PM, Mark Kelly wrote: Hi. Thanks for all the replies. On Saturday 05 Mar 2011 at 22:11 Simon J Welsh wrote: On 6/03/2011, at 11:08 AM, Shawn McKenzie wrote: $regex = '/([^]+)/'; Shawn, this regex gets me two copies of each string - one with and one without the

[PHP] Re: Regex for extracting quoted strings

2011-03-05 Thread Nathan Rixham
Mark Kelly wrote: Hi. I'm hoping someone can help me extract text between double quotes from a string. $regex = 'some magic'; $r = preg_match($regex, $sentence, $phrases); So, if $sentence = 'Dave said This is it. Nope, that is the wrong colour she replied.'; I want $phrases to contain

[PHP] Re: Regex for extracting quoted strings

2011-03-05 Thread Shawn McKenzie
On 03/05/2011 09:26 AM, Mark Kelly wrote: Hi. I'm hoping someone can help me extract text between double quotes from a string. $regex = 'some magic'; $r = preg_match($regex, $sentence, $phrases); So, if $sentence = 'Dave said This is it. Nope, that is the wrong colour she

Re: [PHP] Re: Regex for extracting quoted strings

2011-03-05 Thread Simon J Welsh
On 6/03/2011, at 11:08 AM, Shawn McKenzie wrote: On 03/05/2011 09:26 AM, Mark Kelly wrote: Hi. I'm hoping someone can help me extract text between double quotes from a string. $regex = 'some magic'; $r = preg_match($regex, $sentence, $phrases); So, if $sentence = 'Dave said

Re: [PHP] Re: Regex for extracting quoted strings

2011-03-05 Thread Mark Kelly
Hi. Thanks for all the replies. On Saturday 05 Mar 2011 at 22:11 Simon J Welsh wrote: On 6/03/2011, at 11:08 AM, Shawn McKenzie wrote: $regex = '/([^]+)/'; Shawn, this regex gets me two copies of each string - one with and one without the double quotes - as did the one Nathan posted

Re: [PHP] Re: Regex for extracting quoted strings

2011-03-05 Thread Shuo
Maybe this will help. $regex = '/(?=)[^.]*(?=)/'; $r = preg_match_all($regex, $sentence, $phrases);