# my $regstr = join '', # # The regular expression (PPI::Token::Regexp::Substitute): # # # # s{ # # (?# probulary ) # # \d+ # digits # # [ ] # space # # \s+ # spaces # # \w+ # words # # }{}gx # # # # matches as follows: # #r: PPIx::Regexp / PPI::Token::Regexp::Substitute # #r= "s{\n(?# probulary )\n\\d+ # digits\n[ ] # space\n\\s+ # spaces\n\\w+ # words \n}{}gx" # # # address=/3/C0 # xRe::Token::Structure # Represent structural elements. "s", # ------------------------------------------------------------------ # address=/3/C1 # xRe::Structure::Regexp # Represent the top-level regular expression # ------ # address=/3/C1/S0 # xRe::Token::Delimiter # Represent the delimiters of the regular expression "{", # ------------------------------------------------------------------ "\n", # address=/3/C1/S2 # xRe::Token::Comment "(?# probulary )", # ------------------------------------------------------------------ "\n", # address=/3/C1/C0 # xRe::Token::CharClass::Simple # This class represents a simple character class # \d Match a decimal digit character. # [0-9] # L # L # L "\\d", # ---------- # address=/3/C1/C1 # xRe::Token::Quantifier # Represent an atomic quantifier. # match preceding pattern 1 or more times # (matching the most amount possible) # match the preceding pattern at address=/3/C1/C0 "+", # ---------- " ", # address=/3/C1/C3 # xRe::Token::Comment "# digits\n", # ------------------------------------------------------------------ # address=/3/C1/C4 # xRe::Structure::CharClass # a character class # ------------ # address=/3/C1/C4/S0 # xRe::Token::Structure # Represent structural elements. "[", # ------------------------------------------------------------------ # address=/3/C1/C4/C0 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 32 ) ) alias \N{U+0020} alias \040 alias SPACE alias " ", # ------------------------------------------------------------------ # address=/3/C1/C4/F0 # xRe::Token::Structure # Represent structural elements. "]", # ------------------------------------------------------------------ " ", # address=/3/C1/C6 # xRe::Token::Comment "# space\n", # ------------------------------------------------------------------ # address=/3/C1/C7 # xRe::Token::CharClass::Simple # This class represents a simple character class # \s Match a whitespace character. # L # L "\\s", # ---------- # address=/3/C1/C8 # xRe::Token::Quantifier # Represent an atomic quantifier. # match preceding pattern 1 or more times # (matching the most amount possible) # match the preceding pattern at address=/3/C1/C7 "+", # ---------- " ", # address=/3/C1/C10 # xRe::Token::Comment "# spaces\n", # ------------------------------------------------------------------ # address=/3/C1/C11 # xRe::Token::CharClass::Simple # This class represents a simple character class # \w Match a "word" character. # L # \w matches [a-zA-Z0-9_]. # L # L # L "\\w", # ---------- # address=/3/C1/C12 # xRe::Token::Quantifier # Represent an atomic quantifier. # match preceding pattern 1 or more times # (matching the most amount possible) # match the preceding pattern at address=/3/C1/C11 "+", # ---------- " ", # address=/3/C1/C14 # xRe::Token::Comment "# words \n", # ------------------------------------------------------------------ # address=/3/C1/F0 # xRe::Token::Delimiter # Represent the delimiters of the regular expression "}", # ------------------------------------------------------------------ # address=/3/C2 # xRe::Structure::Replacement # Represent the replacement in s/// # ---- # address=/3/C2/S0 # xRe::Token::Delimiter # Represent the delimiters of the regular expression "{", # ------------------------------------------------------------------ # address=/3/C2/F0 # xRe::Token::Delimiter # Represent the delimiters of the regular expression "}", # ------------------------------------------------------------------ # address=/3/C3 # xRe::Token::Modifier # Represent 1)embedded pattern-match modifiers or 2)(trailing) modifiers for operators match, substitution, regexp constructor # /g Match globally, i.e., find all occurrences. # in list context (@matches=m//g) return all matches; in scalar context($count=m//g) return number of matches # /x disregarding whitespace and comments "gx", # ------------------------------------------------------------------ # ;;;;;;;;;; # __END__ #PPIx::Regexp=HASH(0x179c8a4) s{ (?# probulary ) \d+ # digits [ ] # space \s+ # spaces \w+ # words }{}gx #### $ perl -MPPIx::Regexp -MData::Dump -le " $r=PPIx::Regexp->new(q{s{ \d+ \w+ }{}gx}); dd( $r ); print $r->content; " bless({ children => [ bless({ content => "s" }, "PPIx::Regexp::Token::Structure"), bless({ children => [ bless({ content => "\\d" }, "PPIx::Regexp::Token::CharClass::Simple"), bless({ content => "+" }, "PPIx::Regexp::Token::Quantifier"), bless({ content => " ", perl_version_introduced => "5.000" }, "PPIx::Regexp::Token::Whitespace"), bless({ content => " ", perl_version_introduced => "5.000" }, "PPIx::Regexp::Token::Whitespace"), bless({ content => " ", perl_version_introduced => "5.000" }, "PPIx::Regexp::Token::Whitespace"), bless({ content => " ", perl_version_introduced => "5.000" }, "PPIx::Regexp::Token::Whitespace"), bless({ content => "\\w" }, "PPIx::Regexp::Token::CharClass::Simple"), bless({ content => "+" }, "PPIx::Regexp::Token::Quantifier"), bless({ content => " ", perl_version_introduced => "5.000" }, "PPIx::Regexp::Token::Whitespace"), ], finish => [bless({ content => "}" }, "PPIx::Regexp::Token::Delimiter")], max_capture_number => 0, start => [ bless({ content => "{" }, "PPIx::Regexp::Token::Delimiter"), bless({ content => " ", perl_version_introduced => "5.000" }, "PPIx::Regexp::Token::Whitespace"), ], type => [], }, "PPIx::Regexp::Structure::Regexp"), bless({ children => [], finish => [bless({ content => "}" }, "PPIx::Regexp::Token::Delimiter")], start => [bless({ content => "{" }, "PPIx::Regexp::Token::Delimiter")], type => [], }, "PPIx::Regexp::Structure::Replacement"), bless({ content => "gx", modifiers => { g => 1, x => 1 } }, "PPIx::Regexp::Token::Modifier"), ], effective_modifiers => { g => 1, x => 1 }, failures => 0, source => "s{ \\d+ \\w+ }{}gx", }, "PPIx::Regexp") s{ \d+ \w+ }{}gx