perlrequick, perlintro, Re^3: My Favourite Regex Tools (Was: Parsing a Variable Format String)

#~ two digits, #~ followed by a dash, #~ followed by an optional digit, #~ followed by four digits use Regexp::English; my $re = Regexp::English -> new -> digit -> digit -> literal('-') -> optional -> digit -> end -> digit -> digit -> digit -> digit; print $re; __END__ (?^:\d\d\-(?:\d?)\d\d\d\d)

rxrx describes the regex

\d Match a digit \d Match a digit \- Match a literal '-' character (?: The start of a non-capturing group \d? Match a digit, one-or-zero times (as many as possible +) ) The end of non-capturing group \d Match a digit \d Match a digit \d Match a digit \d Match a digit

wxPPIxregexplain.pl / ppixregexplain.pl says

         
    # my $regstr = join '', ; # The regular expression (PPI::Token::Regexp::Match): ; #
# /(?^:\d\d\-(?:\d?)\d\d\d\d)/
#
# matches as follows:
#r: PPIx::Regexp / PPI::Token::Regexp::Match
#r= "/(?^:\\d\\d\\-(?:\\d?)\\d\\d\\d\\d)/"
#
          "",
      # address=/1/C0 ; xRe::Token::Structure ; Represent structural elements.
#"",
# ------------------------------------------------------------------
               
       # # address=/1/C1 ; xRe::Structure::Regexp ; Represent the top-level regular expression
# perl_version_introduced=5.013006
# ------
            "/",
       # address=/1/C1/S0 ; xRe::Token::Delimiter ; Represent the delimiters of the regular expression
#"/",
# ------------------------------------------------------------------
                     
          # # address=/1/C1/C0 ; xRe::Structure::Modifier ; Represent modifying parentheses
# group but do not capture; Basic clustering
# perl_version_introduced=5.013006
# ------------
                  "(",
          # address=/1/C1/C0/S0 ; xRe::Token::Structure ; Represent structural elements.
#"(",
# ------------------------------------------------------------------
                    "?^:",
           # # address=/1/C1/C0/T0 ; xRe::Token::GroupType::Modifier ; Represent the modifiers in a modifier group.
# perl_version_introduced=5.013006
# mods( match_semantics = d x = 0 m = 0 s = 0 i = 0 )
# (?^) is (?d) is "Depends" or "Dodgy" or "Default"; L<perlunicode/The "Unicode Bug">;
#"?^:",
# ------------------------------------------------------------------
                      "\\d",
            # # address=/1/C1/C0/C0 ; xRe::Token::CharClass::Simple ; This class represents a simple character class
# \d Match a decimal digit character.
# [0-9]
# L<perldebguts/DIGIT>
# L<perlrecharclass/\d>
# L<perlrebackslash/\d>
# (?^) is (?d) is "Depends" or "Dodgy" or "Default"; L<perlunicode/The "Unicode Bug">;
#"\\d",
# ----------------
                      "\\d",
            # # address=/1/C1/C0/C1 ; xRe::Token::CharClass::Simple ; This class represents a simple character class
# \d Match a decimal digit character.
# [0-9]
# L<perldebguts/DIGIT>
# L<perlrecharclass/\d>
# L<perlrebackslash/\d>
# (?^) is (?d) is "Depends" or "Dodgy" or "Default"; L<perlunicode/The "Unicode Bug">;
#"\\d",
# ----------------
                      "\\-",
            # # address=/1/C1/C0/C2 ; xRe::Token::Literal ; a literal character
# ordinal= ord( chr( 45 ) ) alias \N{U+002D} alias \055 alias HYPHEN-MINUS alias -
# (?^) is (?d) is "Depends" or "Dodgy" or "Default"; L<perlunicode/The "Unicode Bug">;
#"\\-",
# ------------------------------------------------------------------
                           
             # # address=/1/C1/C0/C3 ; xRe::Structure::Modifier ; Represent modifying parentheses
# group but do not capture; Basic clustering
# ------------------
                        "(",
             # address=/1/C1/C0/C3/S0 ; xRe::Token::Structure ; Represent structural elements.
#"(",
# ------------------------------------------------------------------
                          "?:",
              # address=/1/C1/C0/C3/T0 ; xRe::Token::GroupType::Modifier ; Represent the modifiers in a modifier group.
#"?:",
# ------------------------------------------------------------------
                            "\\d",
               # # address=/1/C1/C0/C3/C0 ; xRe::Token::CharClass::Simple ; This class represents a simple character class
# \d Match a decimal digit character.
# [0-9]
# L<perldebguts/DIGIT>
# L<perlrecharclass/\d>
# L<perlrebackslash/\d>
# (?^) is (?d) is "Depends" or "Dodgy" or "Default"; L<perlunicode/The "Unicode Bug">;
# (?d) is "Depends" or "Dodgy" or "Default"; L<perlunicode/The "Unicode Bug">;
# (?d) is the old, problematic, pre-5.14 Default character set behavior. Its only use is to force that old behavior.
#"\\d",
# ----------------------
                            "?",
               # # address=/1/C1/C0/C3/C1 ; xRe::Token::Quantifier ; Represent an atomic quantifier.
# match preceding pattern 0 or 1 times; is optional
# (matching the most amount possible)
# match the preceding pattern at address=/1/C1/C0/C3/C0
#"?",
# ----------------------
                        ")",
             # address=/1/C1/C0/C3/F0 ; xRe::Token::Structure ; Represent structural elements.
#")",
# ------------------------------------------------------------------
                      "\\d",
            # # address=/1/C1/C0/C4 ; xRe::Token::CharClass::Simple ; This class represents a simple character class
# \d Match a decimal digit character.
# [0-9]
# L<perldebguts/DIGIT>
# L<perlrecharclass/\d>
# L<perlrebackslash/\d>
# (?^) is (?d) is "Depends" or "Dodgy" or "Default"; L<perlunicode/The "Unicode Bug">;
#"\\d",
# ----------------
                      "\\d",
            # # address=/1/C1/C0/C5 ; xRe::Token::CharClass::Simple ; This class represents a simple character class
# \d Match a decimal digit character.
# [0-9]
# L<perldebguts/DIGIT>
# L<perlrecharclass/\d>
# L<perlrebackslash/\d>
# (?^) is (?d) is "Depends" or "Dodgy" or "Default"; L<perlunicode/The "Unicode Bug">;
#"\\d",
# ----------------
                      "\\d",
            # # address=/1/C1/C0/C6 ; xRe::Token::CharClass::Simple ; This class represents a simple character class
# \d Match a decimal digit character.
# [0-9]
# L<perldebguts/DIGIT>
# L<perlrecharclass/\d>
# L<perlrebackslash/\d>
# (?^) is (?d) is "Depends" or "Dodgy" or "Default"; L<perlunicode/The "Unicode Bug">;
#"\\d",
# ----------------
                      "\\d",
            # # address=/1/C1/C0/C7 ; xRe::Token::CharClass::Simple ; This class represents a simple character class
# \d Match a decimal digit character.
# [0-9]
# L<perldebguts/DIGIT>
# L<perlrecharclass/\d>
# L<perlrebackslash/\d>
# (?^) is (?d) is "Depends" or "Dodgy" or "Default"; L<perlunicode/The "Unicode Bug">;
#"\\d",
# ----------------
                  ")",
          # address=/1/C1/C0/F0 ; xRe::Token::Structure ; Represent structural elements.
#")",
# ------------------------------------------------------------------
            "/",
       # address=/1/C1/F0 ; xRe::Token::Delimiter ; Represent the delimiters of the regular expression
#"/",
# ------------------------------------------------------------------
          "",
      # address=/1/C2 ; xRe::Token::Modifier ; Represent 1)embedded pattern-match modifiers or 2)(trailing) modifiers for operators match, substitution, regexp constructor
#"",
# ------------------------------------------------------------------
         
    ;;;;;;;;;;

In reply to Re: need help with a Perl regular expression by Anonymous Monk
in thread need help with a Perl regular expression by MrSnrub

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.