Regexp::Trie(3pm)
π Hiiiii welcome to Regexp::Trie π
okay so you found the manual page for Regexp::Trie(3pm) and honestly? you're gonna love it here. it's a Perl module (obvi), and it does one thing and it does it so well. sit down, grab a boba, let's go π§β¨
π NAME π
Regexp::Trie β it builds a trie-ized regexp. that's it. that's the whole name. no notes π
β¨ SYNOPSIS β¨
here's the vibe, bestie, copy-paste this and watch it cook:
use Regexp::Trie;
my $rt = Regexp::Trie->new;
for (qw/foobar fooxar foozap fooza/){
$rt->add($_);
}
print $rt->regexp, "\n" # (?-xism:foo(?:bar|xar|zap?))
like. LOOK at that output. four words in, one gorgeously compressed regexp out. the way that foo is just shared by everyone at the function and nobody's duplicating work... it's giving collaboration. it's giving community. π«Ά
πΈ DESCRIPTION πΈ
so this module is basically the faster, simpler little sister of Regexp::Assemble or Regexp::Optimizer. it builds a trie-ized regexp, exactly like the one up there in the synopsis. β¨
here's the tea though β it IS faster than Regexp::Assemble, yes, but the trade-off is that you can only add literals. like, no fancy regex business. so if you write "a+b", it gets treated as "a\+b" β meaning literally the characters a, plus, b. it is NOT "more than one a's followed by b". it does not know what you meant. it does not want to know what you meant. it's a literal girlie and it's staying that way. π
why does this module even exist? bc the author needed something faster than Regexp::Assemble and Regexp::Optimizer, periodt. so if you need way more minute control over your regexps, go use one of those instead. this one is the quick-and-dirty speed demon. ποΈπ¨
π¦ TIPS π¦
want to turn a MASSIVE dictionary into one single regexp that you can load up later? peek at t/dict2rx.pl to see how it's done. and then you can load it like:
my $rx = do 'dict.rx';
obsessed. iconic. big-dictionary energy. π
π EXPORT π
- None. β nope, nothing gets exported. you get what you ask for and nothing more. boundaries, bestie. π§
π SEE ALSO π
go check out these other cuties if you want more:
- Regexp::Optimizer
- Regexp::Assemble
- Regex::PreSuf
π AUTHOR π
Dan Kogai, <dankogai@dan.co.jp> β the mastermind, the main character, the one who said "nah imma build it faster." respect. π«‘
π COPYRIGHT AND LICENSE π
Copyright (C) 2006 by Dan Kogai
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
aaaand that's the whole page, bestie!! this manual shipped as part of perl v5.36.0, dated 2022-10-13 β so yes, this is a certified classic, no cap. go forth and trie-ize responsibly π§β¨π
π¦ where this page comes from
- ubuntu noble: libregexp-trie-perl 0.02-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libregexp-trie-perl 0.02-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libregexp-trie-perl 0.02-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms