> On Wed, 11 May 2005, Murray @ PlanetThoughtful wrote:
> 
> > Hi All,
> >
> > I'd very much appreciate some help building a regular expression for
> > preg_match_all that can differentiate between 'words' and 'phrases'.
> >
> > For example, say I have a string that contains: 'this is an "example of
> a
> > phrase"'
> >
> > I'd like to be able to break that down to:
> >
> > this
> >
> > is
> >
> > an
> >
> > example of a phrase
> >
> 
> I haven't thought this through fully, but what if you exploded the string
> on " into an array.  Then loop through the array and for every even
> element, explode on a space, otherwise just store the whole string into
> the new array.

I think I *may* have solved this at my end.

The following statement seems to work:

preg_match_all('/([\w\-]+?|[(]|[)]|\".+\")/U',strtoupper($prep_sql),$sqlarr)
;

I need to test it out with a whole series of different possible combinations
to see if it behaves the way I want it to, but so far the results are good.

If anyone can see any flaws, I'd love to know about them!

Many thanks,

Murray

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to