Re: Good Regex for general text search

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok, My example was pretty bad.

I was just looking for an easier/more optimal way to look for something
along the lines of
"word1*word2*word3*word4" rather than "word1 word2 word3 word4" as it
currently does.

Actually, I think I have an idea for a way to do what I want without a
regular expression.... I'll have to see how fast it is though before
actually using it.

Thanks anyway.

On 10/2/07, Chris <dmagick@xxxxxxxxx> wrote:
>
> Amos Vryhof wrote:
> > I'm writing a few very simple search scripts.
> >
> > One searches in a few columns of a CSV file, while another just searches
> > through a collection of file names.
> >
> > Currently, I just have it stripping illegal characters from the "needle"
> > and "haystack" then doing a substring search
> >
> > if (substr_count(...)>0) {
> >    return formatted results....
> > }
> >
> > What I'm looking to do is enhance my searches with preg_match.  What I
> > want to do is take my needle and haystack with the illegal strings
> > stripped out, split it down to words, and search for the string, no
> > matter what is between the words.
> >
> > ex: "the cat and the dog"
> >
> > would also return
> >
> > "the cat ran from the bull and dog"
> >
> > I might learn Regular Expressions at some point in the future, but I
> > just haven't had time to yet... so what I need is just what I would use
> > to build my string pattern for preg_match... I'll figure out the rest
> > and change my scripts appropriately.
>
> You're not going to be able to do that with a regular expression because
> the order of the words isn't even the same.
>
> Why would you need to do this with a regex instead of the way it's
> working right now?
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
> _______________________________________________________________________
> This Email has been scanned for viruses by SkyScan.
>
>


-- 
-- 
Amos Vryhof
Assistant Web Developer
Holsteinworld.com
avryhof@xxxxxxxxxxxxxxxxx
1-800-334-1904 Ext 239

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux