Regexp...efHash(3pm)

πŸ“¦
version 0.001 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ¦‹ NAME πŸ¦‹

Regexp::Pattern::DefHash β€” regex patterns related to DefHash. That's the whole assignment, bestie. πŸ’–


✨ VERSION ✨

This document describes version 0.001 of Regexp::Pattern::DefHash (from Perl distribution Regexp-Pattern-DefHash), released on 2021-07-22. Yeah it's a lil vintage, it still eats. πŸŽ€


🌸 SYNOPSIS 🌸

Okay so here's the whole entrance:

use Regexp::Pattern; # exports re()
my $re = re("DefHash::attr");

That's it. You import, you call re(), you get a regex. Iconic behavior, no notes. ✨


πŸ’… DESCRIPTION πŸ’…

Regexp::Pattern is a convention for organizing reusable regex patterns. That's the official word, and it's honestly a whole mood β€” one shared vibe for stashing regexes you actually want to reuse instead of retyping them forty times. 🫢


πŸ‘‘ REGEXP PATTERNS πŸ‘‘

Here come the patterns, and bestie, there are so many examples. I'm listing every single one because we don't skip content in this house. 🏠✨

πŸŽ€ attr

Tags: anchored, capturing

Attribute key.

Examples:

  • Example #1. ".attr" =~ re("DefHash::attr"); # matches
  • Example #2. "._attr" =~ re("DefHash::attr"); # matches
  • Example #3. ".attr1.subattr2" =~ re("DefHash::attr"); # matches
  • Example #4. "prop.attr1" =~ re("DefHash::attr"); # matches
  • Example #5. "_prop._attr1" =~ re("DefHash::attr"); # matches
  • Example #6. "Prop.attr1.subattr2.Subattr3" =~ re("DefHash::attr"); # matches
  • Example #7. "_prop.attr1" =~ re("DefHash::attr"); # matches

Now the nope pile β€” read these carefully, this is where people trip:

  • Cannot start with digit (1). ".0attr" =~ re("DefHash::attr"); # DOESN'T MATCH
  • Cannot start with digit (2). "prop.0attr" =~ re("DefHash::attr"); # DOESN'T MATCH
  • Cannot start with digit (3). "prop.attr.0subattr" =~ re("DefHash::attr"); # DOESN'T MATCH
  • Invalid character: dash (1). ".attr-ibute" =~ re("DefHash::attr"); # DOESN'T MATCH
  • Invalid character: dash (2). "prop-erty.attribute" =~ re("DefHash::attr"); # DOESN'T MATCH
  • Invalid character: dash (3). "prop.attr-ibute" =~ re("DefHash::attr"); # DOESN'T MATCH
  • Invalid character: whitespace (1). "property .attr" =~ re("DefHash::attr"); # DOESN'T MATCH
  • Invalid character: whitespace (2). "property.attr " =~ re("DefHash::attr"); # DOESN'T MATCH
  • Invalid character: whitespace (3). ".attr " =~ re("DefHash::attr"); # DOESN'T MATCH
  • Invalid syntax: dot only. "." =~ re("DefHash::attr"); # DOESN'T MATCH
  • Invalid syntax: double dot. "..attr" =~ re("DefHash::attr"); # DOESN'T MATCH
  • Invalid syntax: dot without attr. "attr." =~ re("DefHash::attr"); # DOESN'T MATCH
  • Invalid syntax: dot without attr (2). "attr.." =~ re("DefHash::attr"); # DOESN'T MATCH
  • Empty. "" =~ re("DefHash::attr"); # DOESN'T MATCH
  • Property, not attribute. "p" =~ re("DefHash::attr"); # DOESN'T MATCH
  • Property, not attribute. "_" =~ re("DefHash::attr"); # DOESN'T MATCH

πŸ¦‹ attr_part

Tags: anchored

Attribute part in attribute key.

Examples:

  • Empty. "" =~ re("DefHash::attr_part"); # DOESN'T MATCH
  • Example #2. "p" =~ re("DefHash::attr_part"); # matches
  • Example #3. "p.q" =~ re("DefHash::attr_part"); # matches
  • Dot prefix must not be included. ".p" =~ re("DefHash::attr_part"); # DOESN'T MATCH
Heads up bestie: that dot prefix? Do not include it. The pattern does not want your leading punctuation. 🚫

πŸ”₯ key

Tags: anchored, capturing

Attribute key or property key.

All keys in defhash must match this pattern. (Yes β€” ALL of them. The bar is on the floor and also it's the ceiling.)

Examples:

  • Example #1. "p" =~ re("DefHash::key"); # matches
  • Example #2. "_" =~ re("DefHash::key"); # matches
  • Example #3. "prop" =~ re("DefHash::key"); # matches
  • Example #4. "Prop2" =~ re("DefHash::key"); # matches
  • Example #5. "prop_" =~ re("DefHash::key"); # matches
  • Cannot start with digit. "0prop" =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid character: dash. "prop-erty" =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid character: whitespace. "property " =~ re("DefHash::key"); # DOESN'T MATCH
  • Example #9. ".attr" =~ re("DefHash::key"); # matches
  • Example #10. "._attr" =~ re("DefHash::key"); # matches
  • Example #11. ".attr1.subattr2" =~ re("DefHash::key"); # matches
  • Example #12. "prop.attr1" =~ re("DefHash::key"); # matches
  • Example #13. "_prop._attr1" =~ re("DefHash::key"); # matches
  • Example #14. "Prop.attr1.subattr2.Subattr3" =~ re("DefHash::key"); # matches
  • Example #15. "_prop.attr1" =~ re("DefHash::key"); # matches

And the do-not-pass-go list:

  • Cannot start with digit (1). ".0attr" =~ re("DefHash::key"); # DOESN'T MATCH
  • Cannot start with digit (2). "prop.0attr" =~ re("DefHash::key"); # DOESN'T MATCH
  • Cannot start with digit (3). "prop.attr.0subattr" =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid character: dash (1). ".attr-ibute" =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid character: dash (2). "prop-erty.attribute" =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid character: dash (3). "prop.attr-ibute" =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid character: whitespace (1). "property .attr" =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid character: whitespace (2). "property.attr " =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid character: whitespace (3). ".attr " =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid syntax: dot only. "." =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid syntax: double dot. "..attr" =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid syntax: dot without attr. "attr." =~ re("DefHash::key"); # DOESN'T MATCH
  • Invalid syntax: dot without attr (2). "attr.." =~ re("DefHash::key"); # DOESN'T MATCH
  • Empty. "" =~ re("DefHash::key"); # DOESN'T MATCH

🌈 prop

Tags: anchored

Property key.

Examples:

  • Example #1. "p" =~ re("DefHash::prop"); # matches
  • Example #2. "_" =~ re("DefHash::prop"); # matches
  • Example #3. "prop" =~ re("DefHash::prop"); # matches
  • Example #4. "Prop2" =~ re("DefHash::prop"); # matches
  • Example #5. "prop_" =~ re("DefHash::prop"); # matches

The rejected ones, respectfully:

  • Cannot start with digit. "0prop" =~ re("DefHash::prop"); # DOESN'T MATCH
  • Invalid character: dash. "prop-erty" =~ re("DefHash::prop"); # DOESN'T MATCH
  • Invalid character: whitespace. "property " =~ re("DefHash::prop"); # DOESN'T MATCH
  • Empty. "" =~ re("DefHash::prop"); # DOESN'T MATCH
  • Attribute, not property. "prop.attr" =~ re("DefHash::prop"); # DOESN'T MATCH
  • Attribute, not property. ".attr" =~ re("DefHash::prop"); # DOESN'T MATCH
Stay in your lane: this one is for property keys. Attributes are not invited to the function. πŸ’…

⭐ prop_or_attr

Tags: anchored, capturing

Attribute key or property key.

All keys in defhash must match this pattern.

Examples:

  • Example #1. "p" =~ re("DefHash::prop_or_attr"); # matches
  • Example #2. "_" =~ re("DefHash::prop_or_attr"); # matches
  • Example #3. "prop" =~ re("DefHash::prop_or_attr"); # matches
  • Example #4. "Prop2" =~ re("DefHash::prop_or_attr"); # matches
  • Example #5. "prop_" =~ re("DefHash::prop_or_attr"); # matches
  • Cannot start with digit. "0prop" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid character: dash. "prop-erty" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid character: whitespace. "property " =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Example #9. ".attr" =~ re("DefHash::prop_or_attr"); # matches
  • Example #10. "._attr" =~ re("DefHash::prop_or_attr"); # matches
  • Example #11. ".attr1.subattr2" =~ re("DefHash::prop_or_attr"); # matches
  • Example #12. "prop.attr1" =~ re("DefHash::prop_or_attr"); # matches
  • Example #13. "_prop._attr1" =~ re("DefHash::prop_or_attr"); # matches
  • Example #14. "Prop.attr1.subattr2.Subattr3" =~ re("DefHash::prop_or_attr"); # matches
  • Example #15. "_prop.attr1" =~ re("DefHash::prop_or_attr"); # matches

And the nuh-uh set:

  • Cannot start with digit (1). ".0attr" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Cannot start with digit (2). "prop.0attr" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Cannot start with digit (3). "prop.attr.0subattr" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid character: dash (1). ".attr-ibute" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid character: dash (2). "prop-erty.attribute" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid character: dash (3). "prop.attr-ibute" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid character: whitespace (1). "property .attr" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid character: whitespace (2). "property.attr " =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid character: whitespace (3). ".attr " =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid syntax: dot only. "." =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid syntax: double dot. "..attr" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid syntax: dot without attr. "attr." =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Invalid syntax: dot without attr (2). "attr.." =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH
  • Empty. "" =~ re("DefHash::prop_or_attr"); # DOESN'T MATCH

🧚 HOMEPAGE 🧚

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


πŸ“ SOURCE πŸ“

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


😭 BUGS 😭

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

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. (Receipts, bestie. Always bring receipts. 🧾✨)


πŸ’œ SEE ALSO πŸ’œ

  • DefHash specification.
  • Regexp::Pattern
  • Some utilities related to Regexp::Pattern: App::RegexpPatternUtils, rpgrep from App::rpgrep.

🫢 AUTHOR 🫢

perlancar <perlancar@cpan.org>


This software is copyright (c) 2021 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 whole page, bestie β€” you ate that. πŸ’… This one's from the User Contributed Perl Documentation corner of the 3pm section, rendered by perl v5.36.0, dated 2022-10-13. Go forth and match some keys. πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from