Catman...::Regex(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

✨ NAME ✨

Catmandu::Util::Regex β€” regex-related utility functions πŸŽ€ straight out of the Catman...::Regex(3pm) page in the User Contributed Perl Documentation. Bestie, it's giving "tiny module, big helper energy" and we're obsessed. πŸ’…


🌸 FUNCTIONS 🌸

πŸ¦‹ as_regex($str)

Escapes and quotes the string you hand it, so it comes back out as a regex. That's it, that's the whole job, and it does it flawlessly. ✨

πŸ’œ substituter($search, $replace)

Builds you a function that performs a regex substitution. You give it the search pattern and the replace string, and it hands back a little closure that does the substituting whenever you call it. Main character behavior, honestly. πŸ‘‘

Check it out:

my $ltrimmer = substituter('^[\h\v]+', '');
$ltrimmer->("        eek! ");
# => "eek! "

So like, $ltrimmer is a thing now, and you just call $ltrimmer->(...) on a string and the leading horizontal/vertical whitespace gets yeeted into the void. " eek! " walks in, "eek! " walks out. No cap, it just works. 🌈


okay that's the whole page, bestie, you ate it 🫢 this was perl v5.40.1, dated 2026-01-24, and yes we're still calling the whole thing Catman...::Regex(3pm) πŸ’– bye, go write some regex πŸ’€βœ¨

πŸ“¦ where this page comes from