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 (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