Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^5: Internal representation of qr// compiled regular expressions

by japhy (Canon)
on May 24, 2006 at 11:46 UTC ( [id://551336]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Internal representation of qr// compiled regular expressions
in thread Internal representation of qr// compiled regular expressions

Yes. The stringification of a Regexp object goes through the magic system. The mg_obj member is how a Regexp object points to the internal representation of itself (the regexp struct).

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
  • Comment on Re^5: Internal representation of qr// compiled regular expressions

Replies are listed 'Best First'.
Re^6: Internal representation of qr//: and what is: "(?^u:" ?
by HelenCr (Monk) on Oct 13, 2012 at 07:35 UTC

    And what is: '(?^u:' ?

    When inspecting (using the EPIC/Eclipse Perl debugger) the internal composition of a compiled regex (for example:

    my $var = qr/abc/;

    then $var shows as:

     '(?^u:abc)'

    What is '(?^u:' ?

      From Extended Patterns:

      (?^alupimsx)
      One or more embedded pattern-match modifiers, to be turned on (or turned off, if preceded by -) for the remainder of the pattern or the remainder of the enclosing pattern group (if any).

      and

      Starting in Perl 5.14, a "^" (caret or circumflex accent) immediately after the "?" is a shorthand equivalent to d-imsx.

      So, (?^u:abc) is shorthand for (?du-imsx:abc), which means (see Modifiers), match the string abc with:

      • /d    “the old, problematic, pre-5.14 Default character set behavior”;
      • /u    using the Unicode character set;
      • -i    with case-sensitive pattern matching;
      • -m    the string not treated as multiple lines ("^" and "$" match at the start or end, respectively, of the string);
      • -s    the "." pattern not matching the newline character; and
      • -x    whitespace and comments treated as patterns to be matched.

      Hope that helps,

      Athanasius <°(((><contra mundum

Log In?
Username:
Password:

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

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

    No recent polls found