The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Regexp::Pattern::Path - Regexp patterns related to path

VERSION

This document describes version 0.002 of Regexp::Pattern::Path (from Perl distribution Regexp-Pattern-Path), released on 2020-01-03.

SYNOPSIS

 use Regexp::Pattern; # exports re()
 my $re = re("Path::dirname_unix");

DESCRIPTION

Regexp::Pattern is a convention for organizing reusable regex patterns.

PATTERNS

  • dirname_unix

    Valid directory name on Unix.

    Just like filename_unix but allows '.' and '..' (strictly speaking they are special pseudonames to refer to current and parent directory).

    Examples:

     "foo" =~ re("Path::dirname_unix");  # matches
    
     "foo bar" =~ re("Path::dirname_unix");  # matches

    Too short.

     "" =~ re("Path::dirname_unix");  # doesn't match

    Too long.

     "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" =~ re("Path::dirname_unix");  # doesn't match

    contains slash.

     "foo/bar" =~ re("Path::dirname_unix");  # doesn't match

    begins with slash.

     "/foo" =~ re("Path::dirname_unix");  # doesn't match

    ends with slash.

     "foo/" =~ re("Path::dirname_unix");  # doesn't match

    contains null (\0).

     "foo\0" =~ re("Path::dirname_unix");  # doesn't match
    
     "." =~ re("Path::dirname_unix");  # matches
    
     ".." =~ re("Path::dirname_unix");  # matches
    
     "..." =~ re("Path::dirname_unix");  # matches
  • filename_unix

    Valid filename on Unix.

    Length must be 1-255 characters. The only characters not allowed include "\0" (null) and "/" (forward slash, for path separator). Also cannot be '.' or '..'.

    Examples:

     "foo" =~ re("Path::filename_unix");  # matches
    
     "foo bar" =~ re("Path::filename_unix");  # matches

    Too short.

     "" =~ re("Path::filename_unix");  # doesn't match

    Too long.

     "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" =~ re("Path::filename_unix");  # doesn't match

    contains slash.

     "foo/bar" =~ re("Path::filename_unix");  # doesn't match

    begins with slash.

     "/foo" =~ re("Path::filename_unix");  # doesn't match

    ends with slash.

     "foo/" =~ re("Path::filename_unix");  # doesn't match

    contains null (\0).

     "foo\0" =~ re("Path::filename_unix");  # doesn't match

    Cannot be ".".

     "." =~ re("Path::filename_unix");  # doesn't match

    Cannot be "..".

     ".." =~ re("Path::filename_unix");  # doesn't match
    
     "..." =~ re("Path::filename_unix");  # matches

HOMEPAGE

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

SOURCE

Source repository is at https://github.com/perlancar/perl-Regexp-Pattern-Path.

BUGS

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

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

Regexp::Pattern

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 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.