in reply to Re: Module suggestions for parsing query words (ala google)?
in thread Module suggestions for parsing query words (ala google)?

Thanks for your reply!

That definitely a good start. at first, I didn't think that regex's would good enough.

I didn't have it in my original post, but I had in mind that the query terms could be multiple words. ie:

name: mike jones location: ny

or perhaps, more explicitly:

name: "mike jones" location: ny

regardless, my regex fu should be good enough to get that figured out.

I'll give this approach a shot and see how far I get.

Replies are listed 'Best First'.
Re^3: Module suggestions for parsing query words (ala google)?
by BrowserUk (Patriarch) on Oct 01, 2010 at 16:19 UTC

    Something like:

    @inputs = ( "name: mike jones location: ny", 'name: "mike jones" location: ny', "name: jones location: ny" );; $re = qr[ (?: (\S+): \s* ) ["']? (.+?) ["']? (?=\s+\S+:|$) ]x;; %h = m[$re]g and pp $_, \%h for @inputs;; ("name: mike jones location: ny", { location => "ny", name => "mike jo +nes" }) ("name: \"mike jones\" location: ny", { location => "ny", name => "mik +e jones" }) ("name: jones location: ny", { location => "ny", name => "jones" })

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Wow!

      Above and beyond the call of duty. This is a tremendous help! Much appreciated.