Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!hacgate!ashtate!dbase!tomr From: tomr@dbase.A-T.COM (Tom Rombouts) Newsgroups: comp.databases Subject: Re: Wildcard searches in dBASE -or- Clipper Keywords: dBASE Clipper Message-ID: <1991Feb8.170828.8844@dbase.A-T.COM> Date: 8 Feb 91 17:08:28 GMT References: <1991Feb6.002241.4960@oeo2.uucp> Reply-To: tomr@dbase.UUCP (Tom Rombouts) Distribution: usa Organization: Ashton-Tate Lines: 39 In article <1991Feb6.002241.4960@oeo2.uucp> greinkem@oeo2.uucp (Mark Greinke) writes: >I hope somebody out there can help me. I am trying to implement a >wildcard indexed search under dBASE III+ (eventually to be compiled >using Clipper, Summer '87). Is there a way to do this? > >Basically if the user inputs a search string such as "BOGOTA" >it would find valid matches in "AMEMBASSY BOGOTA" and > "AMERICAN EMBASSY BOGOTA" and > "AMB BOGOTA" > For the above simple example, the dBASE "$" operator could be used as such: "BOGOTA" $ which would return .T. is "BOGOTA" were anywhere in the character expression. You could use UPPER() (or LOWER() ) on either or both expressions to ignore the case of the letters. Of course, the _real_ way to do this would be to code up a regular expression matching routine in C or .ASM, and link it in to either Clipper or the upcoming Ashton-Tate Professional Compiler. The source for GNU grep is readily available on the net, and chapters 19 and 20 of Sedgewick's "Algorithms in C" discuss the details of pattern matching theory. (Less detailed, but more readable than Knuth.) Also, Blaise's "Power Search" package provides an interesting example of this in .ASM code. Finally, for quick and dirty work, there are several DOS AWK packages, as well as Friendly Finder, Ask Sam or other text retrieval utiliies that would likely work directly on a .DBF type file. (If not, you could first export the data to text format.) Hope this helps.... Tom Rombouts Torrance 'Tater tomr@ashtate.A-T.com V:(213)538-7108