5

I have list(few million rows) of data all of type string. I need to provide search for that list, but my users don't want to use regex(they don't know how to write regex). Can some tell me few options of such Search it must be as strong as of regex search.

My Option : I can provide search by using indexof() of String class.

7
  • 1
    cool idea I would love to see answers :-)
    – Aman J
    Dec 13, 2012 at 5:59
  • put it on the web, let it be indexed by google, make a custom searchbox that queries google but adds +site:yoursite.com: win.
    – Pieter B
    Dec 13, 2012 at 13:20
  • @PieterB gr8 :-) .Can u provide any reference or explain more on ur idea.
    – Aman J
    Dec 19, 2012 at 7:06
  • Not really sure on your purpose but would a solution like this one suit your needs?
    – mpermon
    Dec 26, 2012 at 10:59
  • @AmandeepJiddewar: A simple way to follow PieterB's suggestion is via Google Custom Search . It's basically Google's prepackaged implementation of his suggestion.
    – Brian
    Dec 26, 2012 at 15:56

4 Answers 4

9

Personally I like the idea behind Apple's iTunes Smart Playlist editor:

iTunes Smart Playlist editor

It has a number of rules, which somehow mimic Regular Expressions using a much more simple and clear form. It's really powerful and you may try to look at this direction if you really think that your users should be able to select a columns to search through and define how exactly they want to search.

Otherwise, I think it's a good idea (already mentioned here) to make things as simple as possible by using a Google-powered search or something.

4

There are at least 3 problems with using regular expressions as a UI for searching your data:

  • Regular expressions provide far more capabilities than most people need. For example, it is unlikely your users will need to search for 'any string longer than 9 characters in which the last 3 characters are any characters except X, Y, or Z.' Regular expressions support that type of search. To do so, the syntax (aka the UI) for regular expressions is necessarily complicated. (leading to point #2)
  • Regex syntax is difficult. I have met few developers that know regex syntax well. Instead, they rely on tools like this one.
  • It is unlikely your users need all the capabilities of regex. More likely, they will want search features like: begins with, ends with, contains, does not contain, phrase1 followed by phrase2 within X words, and the ability to match case.

I agree with CJ Franken's suggestion. Pre-populated drop-down boxes with the search features most likely needed by your users would be the simplest UI and would likely meet their needs. You could expand on that by allowing them to tweak each rule with case, data types, quantifiers, etc.

2

You could consider an approach similar to how popular e-mail tools allow specifying rules / filters for automatic organisation of incoming e-mail.

You can specify your data table column names as fields, and the user can describe actions on those fields. Your actions can correspond to regular expression-like instructions, along the lines of "should contain" or "should not contain", "start with", "end with" etc.

Simplistic example (imagine pre-populated drop-down boxes): [Name] [should not contain] "Steve".

1

I would recommend using a slightly more graphical approach, as text-based expressions will always require either strong prior knowledge or a reference at hand.

Perhaps a menu of tokens to insert (along with a short explanation) would suffice.

For example, IFTTT's UI for creating a template for displaying the contents of an RSS feed provides a drop-down menu of "ingredients" such as "Entry Title" and "Entry URL" that simply insert the keywords "{{EntryTitle}}" and "{{EntryURL}}" into the template.

2
  • +1 for introducing IFTTT to me. I cannot use that approach in my case it feels like I binding user to fixed set of text
    – Aman J
    Dec 13, 2012 at 7:15
  • All I'm saying is to put tokens like ., *, (, ), and so on into a menu with labels so that users can know that these tokens even exist and how to use them.
    – fernozzle
    Dec 13, 2012 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.