Regexp...xample(3pm)

πŸ“¦
version 0.2.14 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– Regexp::Pattern::Example β€” the Regexp...xample(3pm) page, but make it cute πŸ’–

okay bestie, welcome to the Regexp::Pattern::Example manual page (that's the Regexp...xample(3pm) one, the terminal just truncates it because it's dramatic like that). it's an example Regexp::Pattern::* module, and yes it's literally called Example, we love a self-aware king. 🫢


✨ NAME ✨

Regexp::Pattern::Example β€” an example Regexp::Pattern::* module. that's it, that's the whole name section, no cap. πŸ’…


🌸 VERSION 🌸

so this doc describes version 0.2.14 of Regexp::Pattern::Example β€” and it comes from the Perl distribution Regexp-Pattern, released on 2020-04-01. iconic date, no notes. πŸ“…


πŸŽ€ SYNOPSIS πŸŽ€

the vibe check, in code:

use Regexp::Pattern; # exports re()
my $re = re("Example::re1");

yeah. that's how you grab a pattern. Regexp::Pattern exports re() and you just... call it. slay. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the whole thing: Regexp::Pattern is a convention for organizing reusable regex patterns.

that's the entire description. a convention. organizing. reusable regex. it's giving infrastructure, it's giving "we're not writing that regex again", it's giving main character energy for your codebase. periodt. πŸ‘‘


πŸ‘‘ PATTERNS πŸ‘‘

okay this is the good part, the actual patterns. buckle up. πŸ“

  • re1

that's it. that's the entry. no description, no examples, just vibes and a name. respect. πŸ™ˆ

  • re2

this is regexp for blah. πŸ’€

and here's a longer description, in Markdown format β€” yes, Markdown, because we're fancy.

Examples:

one that matches:

"123-456" =~ re("Example::re2");  # matches

another example that matches:

"123-456-78901" =~ re("Example::re2");  # matches

an example that does not match:

 123456 =~ re("Example::re2");  # doesn't match

and an example that does not get tested:

 123456 =~ re("Example::re2");  # doesn't match

(yes, those last two look identical. not me noticing. it's fine. it's in the original. moving on bestie 😭)

  • re3

this is a regexp for blah blah.

...

this one is a dynamic pattern β€” it gets generated on-demand. so it's not sitting there waiting, it's being crafted, live, when you ask for it. very main character. ✨

the following arguments are available to customize the generated pattern:

  • variant β€” choose variant. that's the whole description, we keep it real. πŸ’…

Examples:

an example that matches:

"123-456" =~ re("Example::re3", {variant=>"A"});  # matches

an example that doesn't match:

"123-456" =~ re("Example::re3", {variant=>"B"});  # doesn't match
  • re4

this is a regexp that does capturing. so it's out here grabbing groups, we love a regex with hands. 🫢

Examples:

"123-456" =~ re("Example::re4"); # matches, $1=123, $2=456

"foo-bar" =~ re("Example::re4");  # doesn't match

first one matches and you get $1=123 and $2=456. second one? nope. doesn't match. bye. πŸ‘‹

  • re5

this is another regexp that is anchored and does (named) capturing. anchored means it's not letting anything sneak in at the edges β€” it's got boundaries, we respect that. 🧚

Examples:

"123-456" =~ re("Example::re5"); # matches, $+{"cap1"}=123, $+{"cap2"}=456

"something 123-456" =~ re("Example::re5");  # doesn't match

so the first one matches and gives you the named captures $+{"cap1"}=123 and $+{"cap2"}=456. the second one has something hanging out in front of it and because it's anchored, it does not match. rude? no. correct. πŸ’…


🌈 HOMEPAGE 🌈

please visit the project's homepage at <https://metacpan.org/release/Regexp-Pattern>.

like, actually visit it. go. πŸ¦‹


⭐ SOURCE ⭐

source repository is at <https://github.com/perlancar/perl-Regexp-Pattern>.

go read the code bestie, it's right there. πŸ‘€


πŸ’€ BUGS πŸ’€

please report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=Regexp-Pattern>.

and when you submit a bug or a request, please include a test-file or a patch to an existing test-file that illustrates the bug or the desired feature. seriously. a reproduction is the whole gift. don't just say "it's broken", show us. 🎁

🫢 AUTHOR 🫢

perlancar <perlancar@cpan.org>


this software is copyright (c) 2020, 2019, 2018, 2016 by perlancar@cpan.org.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the page!! πŸ’– written for perl v5.36.0, dated 2022-11-29, and yeah the header still says Regexp...xample(3pm) because terminals love to abbreviate. mwah. take care of your regexes, hydrate, and remember: reuse your patterns. πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from