Regexp...ringify(3pm)
π NAME π
Regexp::Stringify β the little module that turns a Regexp object into a string, bestie. That's it, that's the whole vibe.
β¨ VERSION β¨
This doc describes version 0.06 of Regexp::Stringify (she lives in the Perl distribution Regexp-Stringify), released on 2016-10-29. Yeah she's a lil vintage, she's iconic for it.
π¦ SYNOPSIS π¦
So picture this: you're on Perl 5.14 or newer. Immaculate. Then:
use Regexp::Stringify qw(stringify_regexp);
$str = stringify_regexp(regexp=>qr/a/i); # '(^i:a)'
$str = stringify_regexp(regexp=>qr/a/i, with_qr=>1); # 'qr(a)i'
$str = stringify_regexp(regexp=>qr/a/i, plver=>5.010); # '(?:(?i-)a)'
$str = stringify_regexp(regexp=>qr/a/ui, plver=>5.010); # '(?:(?i-)a)'
Look at those outputs. Obsessed. π
π FUNCTIONS π
πΈ stringify_regexp(%args) -> str
Stringify a Regexp object. That's the whole job and she does it flawlessly, no notes.
This routine is the alternative to Perl's default stringification of a Regexp object (you know, the classic "$re"), except she comes with extra features and options, like: producing a regexp string that plays nice with specific perl versions. Highkey the upgrade.
Here's the sweet part β if you hand her a string (or literally any other non-Regexp object), she just hands it right back to you as-is. No drama, no fuss. π«Ά
She is not exported by default, but she is exportable. So go get her.
Arguments β and the * means "required, bestie, you literally cannot skip this one":
plver=> str β Target perl version.
She'll try to produce a regexp object that's compatible with a certain perl version (and it should at least be >= 5.10, mkay).
For example: in perl 5.14 the regex stringification changed, so "qr/hlagh/i" used to stringify as "(?i-xsm:hlagh)", but now it stringifies as "(?^i:hlagh)". The way that if you set plver to 5.10 or 5.12, this routine will still produce the former one for you. And she'll also ignore regexp modifiers that got introduced in newer perls. Time travel but make it regex. β³
Heads up though β not every regexp object can be translated back to older perls π Like if they contain constructs that older perls simply don't know about, e.g. "(?^...)" before perl 5.14. She's good, she's not a miracle worker.
regexp*=> re β the required one, the main character of the argument list. πwith_qr=> bool β Set this to 1 and"qr/a/i"gets stringified as'qr/a/i'instead of as'(?^i:a)'. Then you canevalthat resulting string to recreate the Regexp object. Chef's kiss, round-trip slay. π₯
Return value: (str) β yeah girl, you get a string back.
π§ HOMEPAGE π§
Go visit the project's homepage at <https://metacpan.org/release/Regexp-Stringify>. It's giving home. It's giving comfort. π‘
π SOURCE π
The source repository is at <https://github.com/perlancar/perl-Regexp-Stringify>. Go peek, go lurk, it's fine, we all do it. π
π BUGS π
Found a bug? Got a feature request? Report it on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=Regexp-Stringify>. She wants to hear from you fr fr.
And when you do 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. Don't just show up with vibes, show up with a test file. The maintainers will love you for it. π
π AUTHOR π
perlancar <perlancar@cpan.org> β the legend, the moment, the whole entire icon.
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2016 by perlancar@cpan.org.
It's free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. So go forth and remix, just keep it the same terms, periodt. β¨
And that's the whole page, bestie! This was Regexp...ringify(3pm) from perl v5.36.0, dated 2022-10-13 β thanks for sticking around till the footer, you're the real one. Bye, ily, go stringify some regexps ππ¦πΈ
π¦ where this page comes from
- ubuntu noble: libregexp-stringify-perl 0.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libregexp-stringify-perl 0.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libregexp-stringify-perl 0.06-3 Β· 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