Parqus - parse a search query string
version 0.03
use Parqus; my $parser = Parqus->new( keywords => [ qw/name title/ ] ); my $res; $res = $parser->process('title:"bar baz" foo title: meh'); # { # words => ['foo'], # keywords => { # title => [ # 'bar baz', # 'meh', # ] # }, # } $res = $parser->process('title:"bar baz" title: meh'); # { # keywords => { # title => [ # 'bar baz', # 'meh', # ] # }, # } $res = $parser->process('foo bar baz'); # { # words => ['foo', 'bar', 'baz'], # } $res = $parser->process('tag: inactive'); # { # errors => { # 'Parse Error: Invalid search query.' # }, # }
Parqus (PArse QUery String) parses a search-engine like string into a perl structure
my $parser = Parqus->new( %options );
keywords => [ qw/name title/ ]
the list of keywords you want to recognise.
regular expression to capture words. (default: [qr![\w-]+!xms])
[qr![\w-]+!xms]
array of characters used to delimit strings. (default: ['"])
['"]
Regexp::Grammars, Search::Query, Search::Query::Dialect::DBIxClass
David Schmidt <davewood@cpan.org>
This software is copyright (c) 2020 by David Schmidt.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Parqus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parqus
CPAN shell
perl -MCPAN -e shell install Parqus
For more information on module installation, please visit the detailed CPAN module installation guide.