dimar has asked for the wisdom of the Perl Monks concerning the following question:
Goal: There is a simple script that searches through flat text files based on a simple 'query string.' The query string is supplied by the user. The goal is to allow the user to supply 'wildcards' in her query string. The syntax for queries is very minimal (i.e., dumb flat search for a string with no fancy boolean operators, no filtering capabilities, no letter-case distinctions).
Question:What is the best way to process a user-supplied search 'query' such that a user is allowed to include simple wildcard characters. (eg not full-blown RegEx) For example, if the user supplies:
The script should return all matching items in the flat file:i*ation
But the script should not return:invitation information Isolation InFlaTiOn IATION
In our nation it requires concentration fiat ionizing
Is the best approach simply to take the user input and translate that into a full-blown RegEx, and then use that? Devising a RegEx that meets the requirement is no problem, but it seems like a potential red-flag to be post processing a user-supplied into a RegEx for some reason. Perhaps there is a better way to approach this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RegEx for users who dont know RegEx
by ikegami (Patriarch) on Dec 23, 2004 at 17:23 UTC | |
by The Mad Hatter (Priest) on Dec 23, 2004 at 17:36 UTC | |
by ikegami (Patriarch) on Dec 23, 2004 at 17:39 UTC | |
|
Re: RegEx for users who dont know RegEx
by The Mad Hatter (Priest) on Dec 23, 2004 at 17:18 UTC | |
by ikegami (Patriarch) on Dec 23, 2004 at 17:30 UTC | |
by The Mad Hatter (Priest) on Dec 23, 2004 at 17:39 UTC | |
|
Re: RegEx for users who dont know RegEx
by inman (Curate) on Dec 24, 2004 at 12:29 UTC |