NAME
Regexp::Pattern::IntRange - Regexp patterns related to integer ranges
VERSION
This document describes version 0.001 of Regexp::Pattern::IntRange (from Perl distribution Regexp-Pattern-IntRange), released on 2021-07-17.
SYNOPSIS
use Regexp::Pattern; # exports re()
my $re = re("IntRange::int_range");
DESCRIPTION
Regexp::Pattern is a convention for organizing reusable regex patterns.
REGEXP PATTERNS
int_range
Integer range (sequence of ints/simple ranges), e.g. 1 / -5-7 / 1,10 / 1,5-7,10.
Currently does not check that start value in a simple range must not be greater than end value.
Examples:
Empty string.
"" =~ re("IntRange::int_range"); # DOESN'T MATCHExample #2.
1 =~ re("IntRange::int_range"); # matchesExample #3.
-2 =~ re("IntRange::int_range"); # matchesFloat.
1.5 =~ re("IntRange::int_range"); # DOESN'T MATCHExample #5.
"1-1" =~ re("IntRange::int_range"); # matchesExample #6.
"1-2" =~ re("IntRange::int_range"); # matchesExample #7.
"1 - 2" =~ re("IntRange::int_range"); # matchesExample #8.
"0-100" =~ re("IntRange::int_range"); # matchesExample #9.
"-1-2" =~ re("IntRange::int_range"); # matchesExample #10.
"-10--1" =~ re("IntRange::int_range"); # matchesMissing end value.
"1-" =~ re("IntRange::int_range"); # DOESN'T MATCHExample #12.
"1-1.5" =~ re("IntRange::int_range"); # DOESN'T MATCHInvalid simple int range syntax.
"1-2-3" =~ re("IntRange::int_range"); # DOESN'T MATCHLeading and trailing whitespace is currently not allowed.
" 1-2 " =~ re("IntRange::int_range"); # DOESN'T MATCHExample #15.
"1,2" =~ re("IntRange::int_range"); # matchesExample #16.
"1 , 2" =~ re("IntRange::int_range"); # matchesExample #17.
"1,2,-3,4" =~ re("IntRange::int_range"); # matchesFloat.
"1,2,-3,4.5" =~ re("IntRange::int_range"); # DOESN'T MATCHDangling comma is currently not allowed.
"1," =~ re("IntRange::int_range"); # DOESN'T MATCHMultiple commas are currently not allowed.
"1,,2" =~ re("IntRange::int_range"); # DOESN'T MATCHExample #21.
"1,2-5" =~ re("IntRange::int_range"); # matchesExample #22.
"-1,-2-5,7,9-9" =~ re("IntRange::int_range"); # matchessimple_int_range
Simple integer range, e.g. 1-10 / -2-7.
Currently does not check that start value must not be greater than end value.
Examples:
Empty string.
"" =~ re("IntRange::simple_int_range"); # DOESN'T MATCHNot a range but single positive integer.
1 =~ re("IntRange::simple_int_range"); # DOESN'T MATCHNot a range but single negative integer.
-2 =~ re("IntRange::simple_int_range"); # DOESN'T MATCHExample #4.
"1-1" =~ re("IntRange::simple_int_range"); # matchesExample #5.
"1-2" =~ re("IntRange::simple_int_range"); # matchesExample #6.
"1 - 2" =~ re("IntRange::simple_int_range"); # matchesExample #7.
"0-100" =~ re("IntRange::simple_int_range"); # matchesExample #8.
"-1-2" =~ re("IntRange::simple_int_range"); # matchesExample #9.
"-10--1" =~ re("IntRange::simple_int_range"); # matchesMissing end value.
"1-" =~ re("IntRange::simple_int_range"); # DOESN'T MATCHExample #11.
"1-1.5" =~ re("IntRange::simple_int_range"); # DOESN'T MATCHInvalid syntax.
"1-2-3" =~ re("IntRange::simple_int_range"); # DOESN'T MATCHLeading and trailing whitespace is currently not allowed.
" 1-2 " =~ re("IntRange::simple_int_range"); # DOESN'T MATCHsimple_int_seq
Simple integer sequence, e.g. 1,-3,12.
Examples:
Empty string.
"" =~ re("IntRange::simple_int_seq"); # DOESN'T MATCHA range m-n is not valid in simple integer sequence.
"1-2" =~ re("IntRange::simple_int_seq"); # DOESN'T MATCHDangling comma is currently not allowed.
"1," =~ re("IntRange::simple_int_seq"); # DOESN'T MATCHMultiple commas are currently not allowed.
"1,,2" =~ re("IntRange::simple_int_seq"); # DOESN'T MATCHFloat.
1.2 =~ re("IntRange::simple_int_seq"); # DOESN'T MATCHExample #6.
1 =~ re("IntRange::simple_int_seq"); # matchesExample #7.
"1,2" =~ re("IntRange::simple_int_seq"); # matchesExample #8.
"1 , 2" =~ re("IntRange::simple_int_seq"); # matchesExample #9.
"1,2,-3,4" =~ re("IntRange::simple_int_seq"); # matchessimple_uint_range
Simple unsigned integer range, e.g. 1-10 / 2-7.
Currently does not check that start value must not be greater than end value.
Examples:
Empty string.
"" =~ re("IntRange::simple_uint_range"); # DOESN'T MATCHNot a range but single positive integer.
1 =~ re("IntRange::simple_uint_range"); # DOESN'T MATCHNot a range but single negative integer.
-2 =~ re("IntRange::simple_uint_range"); # DOESN'T MATCHExample #4.
"1-1" =~ re("IntRange::simple_uint_range"); # matchesExample #5.
"1-2" =~ re("IntRange::simple_uint_range"); # matchesExample #6.
"1 - 2" =~ re("IntRange::simple_uint_range"); # matchesExample #7.
"0-100" =~ re("IntRange::simple_uint_range"); # matchesNegative.
"-1-2" =~ re("IntRange::simple_uint_range"); # DOESN'T MATCHNegative.
"-10--1" =~ re("IntRange::simple_uint_range"); # DOESN'T MATCHMissing end value.
"1-" =~ re("IntRange::simple_uint_range"); # DOESN'T MATCHExample #11.
"1-1.5" =~ re("IntRange::simple_uint_range"); # DOESN'T MATCHInvalid syntax.
"1-2-3" =~ re("IntRange::simple_uint_range"); # DOESN'T MATCHLeading and trailing whitespace is currently not allowed.
" 1-2 " =~ re("IntRange::simple_uint_range"); # DOESN'T MATCHsimple_uint_seq
Simple unsigned integer sequence, e.g. 1,3,12.
Examples:
Empty string.
"" =~ re("IntRange::simple_uint_seq"); # DOESN'T MATCHA range m-n is not valid in simple integer sequence.
"1-2" =~ re("IntRange::simple_uint_seq"); # DOESN'T MATCHDangling comma is currently not allowed.
"1," =~ re("IntRange::simple_uint_seq"); # DOESN'T MATCHMultiple commas are currently not allowed.
"1,,2" =~ re("IntRange::simple_uint_seq"); # DOESN'T MATCHFloat.
1.2 =~ re("IntRange::simple_uint_seq"); # DOESN'T MATCHExample #6.
1 =~ re("IntRange::simple_uint_seq"); # matchesExample #7.
"1,2" =~ re("IntRange::simple_uint_seq"); # matchesExample #8.
"1 , 2" =~ re("IntRange::simple_uint_seq"); # matchesNegative.
"1,2,-3,4" =~ re("IntRange::simple_uint_seq"); # DOESN'T MATCHuint_range
Unsigned integer range (sequence of uints/simple ranges), e.g. 1 / 5-7 / 1,10 / 1,5-7,10.
Currently does not check that start value in a simple range must not be greater than end value.
Examples:
Empty string.
"" =~ re("IntRange::uint_range"); # DOESN'T MATCHExample #2.
1 =~ re("IntRange::uint_range"); # matchesNegative.
-2 =~ re("IntRange::uint_range"); # DOESN'T MATCHFloat.
1.5 =~ re("IntRange::uint_range"); # DOESN'T MATCHExample #5.
"1-1" =~ re("IntRange::uint_range"); # matchesExample #6.
"1-2" =~ re("IntRange::uint_range"); # matchesExample #7.
"1 - 2" =~ re("IntRange::uint_range"); # matchesExample #8.
"0-100" =~ re("IntRange::uint_range"); # matchesNegative.
"-1-2" =~ re("IntRange::uint_range"); # DOESN'T MATCHNegative.
"-10--1" =~ re("IntRange::uint_range"); # DOESN'T MATCHMissing end value.
"1-" =~ re("IntRange::uint_range"); # DOESN'T MATCHExample #12.
"1-1.5" =~ re("IntRange::uint_range"); # DOESN'T MATCHInvalid simple int range syntax.
"1-2-3" =~ re("IntRange::uint_range"); # DOESN'T MATCHLeading and trailing whitespace is currently not allowed.
" 1-2 " =~ re("IntRange::uint_range"); # DOESN'T MATCHExample #15.
"1,2" =~ re("IntRange::uint_range"); # matchesExample #16.
"1 , 2" =~ re("IntRange::uint_range"); # matchesNegative.
"1,2,-3,4" =~ re("IntRange::uint_range"); # DOESN'T MATCHFloat.
"1,2,-3,4.5" =~ re("IntRange::uint_range"); # DOESN'T MATCHDangling comma is currently not allowed.
"1," =~ re("IntRange::uint_range"); # DOESN'T MATCHMultiple commas are currently not allowed.
"1,,2" =~ re("IntRange::uint_range"); # DOESN'T MATCHExample #21.
"1,2-5" =~ re("IntRange::uint_range"); # matchesNegative.
"-1,-2-5,7,9-9" =~ re("IntRange::uint_range"); # DOESN'T MATCH
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/Regexp-Pattern-IntRange.
SOURCE
Source repository is at https://github.com/perlancar/perl-Regexp-Pattern-IntRange.
BUGS
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Regexp-Pattern-IntRange
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.
SEE ALSO
Some utilities related to Regexp::Pattern: App::RegexpPatternUtils, rpgrep from App::rpgrep.
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
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.