Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Beginner confused with string matching

by Anonymous Monk
on Apr 09, 2015 at 15:03 UTC ( [id://1122954]=note: print w/replies, xml ) Need Help??


in reply to Beginner confused with string matching

How would I go about deciphering the thing after $val?

use rxrx, Re^2: ppiwx / wxPPI / wxppixregexp ppixregexplain.pl wxPPIxregexplain.pl PPIx::Regexp::xplain because YAPE::Regex::Explain is dead, Re^4: My Favourite Regex Tools (Was: Parsing a Variable Format String)... so you get

^ # Match only if at start of string (or line) [ ]+ # Match any of the listed characters, one-or- +more times (as many as possible) Pin # Match a literal sequence ("Pin") : # Match a literal ':' character [ ]* # Match any of the listed characters, zero-or +-more times (as many as possible) ( # The start of a capturing block ($1) [^\.]* # Match any character not listed, zero-or-m +ore times (as many as possible) ) # The end of $1 \. # Match a literal '.' character ( # The start of a capturing block ($2) [^ ]* # Match any character not listed, zero-or-m +ore times (as many as possible) ) # The end of $2 [ ]* # Match any of the listed characters, zero-or +-more times (as many as possible) out # Match a literal sequence ("out")

or

# my $regstr = join '', # # The regular expression (PPI::Token::Regexp::Match): # # # # /^[ ]+Pin:[ ]*([^\.]*)\.([^ ]*)[ ]*out/ # # # # matches as follows: # #r: PPIx::Regexp / PPI::Token::Regexp::Match # #r= "/^[ ]+Pin:[ ]*([^\\.]*)\\.([^ ]*)[ ]*out/" # # # address=/2/C0 # xRe::Token::Structure # Represent structural elements. "", # ------------------------------------------------------------------ # address=/2/C1 # xRe::Structure::Regexp # Represent the top-level regular expression # ------ # address=/2/C1/S0 # xRe::Token::Delimiter # Represent the delimiters of the regular expression "/", # ------------------------------------------------------------------ # address=/2/C1/C0 # xRe::Token::Assertion # simple zero-width assertion (zero-length, between pos() +itions) # match the beginning of the string "^", # ------------------------------------------------------------------ # address=/2/C1/C1 # xRe::Structure::CharClass # a character class # ------------ # address=/2/C1/C1/S0 # xRe::Token::Structure # Represent structural elements. "[", # ------------------------------------------------------------------ # address=/2/C1/C1/C0 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 32 ) ) alias \N{U+0020} alias +\040 alias SPACE alias " ", # ------------------------------------------------------------------ # address=/2/C1/C1/F0 # xRe::Token::Structure # Represent structural elements. "]", # ------------------------------------------------------------------ # address=/2/C1/C2 # 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=/2/C1/C1 "+", # ---------- # address=/2/C1/C3 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 80 ) ) alias \N{U+0050} alias \120 a +lias LATIN CAPITAL LETTER P alias P "P", # ------------------------------------------------------------------ # address=/2/C1/C4 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 105 ) ) alias \N{U+0069} alias \151 +alias LATIN SMALL LETTER I alias i "i", # ------------------------------------------------------------------ # address=/2/C1/C5 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 110 ) ) alias \N{U+006E} alias \156 +alias LATIN SMALL LETTER N alias n "n", # ------------------------------------------------------------------ # address=/2/C1/C6 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 58 ) ) alias \N{U+003A} alias \072 a +lias COLON alias : ":", # ------------------------------------------------------------------ # address=/2/C1/C7 # xRe::Structure::CharClass # a character class # ------------ # address=/2/C1/C7/S0 # xRe::Token::Structure # Represent structural elements. "[", # ------------------------------------------------------------------ # address=/2/C1/C7/C0 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 32 ) ) alias \N{U+0020} alias +\040 alias SPACE alias " ", # ------------------------------------------------------------------ # address=/2/C1/C7/F0 # xRe::Token::Structure # Represent structural elements. "]", # ------------------------------------------------------------------ # address=/2/C1/C8 # xRe::Token::Quantifier # Represent an atomic quantifier. # match preceding pattern 0 or more times # (matching the most amount possible) # match the preceding pattern at address=/2/C1/C7 "*", # ---------- # address=/2/C1/C9 # xRe::Structure::Capture # Represent capture parentheses. # number=1 alias "$1" or "\1" # ------------ # address=/2/C1/C9/S0 # xRe::Token::Structure # Represent structural elements. "(", # ------------------------------------------------------------------ # address=/2/C1/C9/C0 # xRe::Structure::CharClass # a character class # ------------------ # address=/2/C1/C9/C0/S0 # xRe::Token::Structure # Represent structural elements. "[", # ------------------------------------------------------------------ # address=/2/C1/C9/C0/T0 # xRe::Token::Operator # Represent an operator. # Character class inversion (all characters exc +ept the following) "^", # ------------------------------------------------------------------ # address=/2/C1/C9/C0/C0 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 46 ) ) alias \N{U+002E} +alias \056 alias PERIOD alias . "\\.", # ------------------------------------------------------------------ # address=/2/C1/C9/C0/F0 # xRe::Token::Structure # Represent structural elements. "]", # ------------------------------------------------------------------ # address=/2/C1/C9/C1 # xRe::Token::Quantifier # Represent an atomic quantifier. # match preceding pattern 0 or more times # (matching the most amount possible) # match the preceding pattern at address=/2/C1/C9/C +0 "*", # ---------------- # address=/2/C1/C9/F0 # xRe::Token::Structure # Represent structural elements. # end of grouping for number=1 alias "$1" or "\1" ")", # ------------------------------------------------------------------ # address=/2/C1/C10 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 46 ) ) alias \N{U+002E} alias \056 a +lias PERIOD alias . "\\.", # ------------------------------------------------------------------ # address=/2/C1/C11 # xRe::Structure::Capture # Represent capture parentheses. # number=2 alias "$2" or "\2" # ------------ # address=/2/C1/C11/S0 # xRe::Token::Structure # Represent structural elements. "(", # ------------------------------------------------------------------ # address=/2/C1/C11/C0 # xRe::Structure::CharClass # a character class # ------------------ # address=/2/C1/C11/C0/S0 # xRe::Token::Structure # Represent structural elements. "[", # ------------------------------------------------------------------ # address=/2/C1/C11/C0/T0 # xRe::Token::Operator # Represent an operator. # Character class inversion (all characters exc +ept the following) "^", # ------------------------------------------------------------------ # address=/2/C1/C11/C0/C0 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 32 ) ) alias \N{U+0020} +alias \040 alias SPACE alias " ", # ------------------------------------------------------------------ # address=/2/C1/C11/C0/F0 # xRe::Token::Structure # Represent structural elements. "]", # ------------------------------------------------------------------ # address=/2/C1/C11/C1 # xRe::Token::Quantifier # Represent an atomic quantifier. # match preceding pattern 0 or more times # (matching the most amount possible) # match the preceding pattern at address=/2/C1/C11/ +C0 "*", # ---------------- # address=/2/C1/C11/F0 # xRe::Token::Structure # Represent structural elements. # end of grouping for number=2 alias "$2" or "\2" ")", # ------------------------------------------------------------------ # address=/2/C1/C12 # xRe::Structure::CharClass # a character class # ------------ # address=/2/C1/C12/S0 # xRe::Token::Structure # Represent structural elements. "[", # ------------------------------------------------------------------ # address=/2/C1/C12/C0 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 32 ) ) alias \N{U+0020} alias +\040 alias SPACE alias " ", # ------------------------------------------------------------------ # address=/2/C1/C12/F0 # xRe::Token::Structure # Represent structural elements. "]", # ------------------------------------------------------------------ # address=/2/C1/C13 # xRe::Token::Quantifier # Represent an atomic quantifier. # match preceding pattern 0 or more times # (matching the most amount possible) # match the preceding pattern at address=/2/C1/C12 "*", # ---------- # address=/2/C1/C14 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 111 ) ) alias \N{U+006F} alias \157 +alias LATIN SMALL LETTER O alias o "o", # ------------------------------------------------------------------ # address=/2/C1/C15 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 117 ) ) alias \N{U+0075} alias \165 +alias LATIN SMALL LETTER U alias u "u", # ------------------------------------------------------------------ # address=/2/C1/C16 # xRe::Token::Literal # a literal character # ordinal= ord( chr( 116 ) ) alias \N{U+0074} alias \164 +alias LATIN SMALL LETTER T alias t "t", # ------------------------------------------------------------------ # address=/2/C1/F0 # xRe::Token::Delimiter # Represent the delimiters of the regular expression "/", # ------------------------------------------------------------------ # address=/2/C2 # xRe::Token::Modifier # Represent 1)embedded pattern-match modifiers or 2)(trailing) +modifiers for operators match, substitution, regexp constructor "", # ------------------------------------------------------------------ # ;;;;;;;;;; # __END__ #PPIx::Regexp=HASH(0x178e4d4) /^[ ]+Pin:[ ]*([^\.]*)\.([^ ]*)[ ]*out/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1122954]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-24 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found