RegEx help
Lloyd Butler
lbutler at on.pelmorex.com
Wed Jul 2 11:58:33 CDT 2003
Eric,
Let me first preface this by saying that I do not use RegEx much.
Since you are not sure what they will search on, what about building
the search criteria up?
You put the string into a temporary variables so that you can play
with them. In one replace the dots with the '\\.'. In one you can put remove
any dats and put '\\.' between each letter and then in another replace the
upper case letters with '[A-Z]' then you can build your query sring by
appending the two together with an OR '|'.
they enter MGM, your routine ends up with
WHERE fld LIKE 'MGM|M\\.G\\.M\\.|M[A-Z][A-Z]'
they enter M.G.M, your routine ends up with
WHERE fld LIKE 'M\\.G\\.M|M\\.G\\.M\\.|M[A-Z][A-Z]'
they enter M.G.M., your routine ends up with
WHERE fld LIKE 'M\\.G\\.M\\.|M\\.G\\.M\\.|M[A-Z][A-Z]' f
they enter Moose, your routine ends up with
WHERE fld LIKE 'Moose|M\\.\\o\\.o\\.s\\.e\\.'
they enter MoM, your routine ends up with
WHERE fld LIKE 'MoM|M\\.\\o\\.M\\.|Mo[A-Z]'
This will find some words that are outside of what you want, but by
using the case of the letters, it may help narrow the list for ya,
especially for acronyms. You don't want to replace the lower case letters or
then you might just as well search for *.
It is not a perfect solution, but it is functional.
Lloyd Butler
Product and System Development Supervisor
TWN Commercial Services
lbutler at on.pelmorex.com
p: 905.566.9511x286
f: 905.566.9370
> First, thanks for your answer.
>
> > "M.G.M" -- you mean that user type DOTS ?
> > and you want find MGM ?
>
> Yes. You know, the Metro Goldwin Mayer may be also called "MGM" or "M.G.M"
>
> > Then you need first of all self correct user's input to "MGM"
> Alas, users are unpredictable and not that flexible !
> Some will input "MGM" and others "M.G.M" or even "M.G.M."
>
> > To do this you need query as
> > WHERE fld LIKE 'M.*G.*M'
> > Here '.*' say that between M and G can be zero or any number of any
> chars.
>
> Good idea, but this will also find records like "magma", "my genius mind",
> etc.
> I'd just like to escape/ignore the dot character...
> Is that possible?
>
> Thanks again for your help.
> Eric
>
>
> ------------------------------
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
>
>
> End of Valentina Digest, Vol 7, Issue 5
> ***************************************
>
>
More information about the Valentina
mailing list