in reply to Re^3: Strange regex to test for newlines: /.*\z/
in thread Strange regex to test for newlines: /.*\z/

Sorry, I still don't get it.

Obviously /\z/ matches the string "f\n", so why should it fail to match if I prepend it with something that matches the empty string? This should be independent of where the end of the string is considered to be.

And why does /.?\z/ match and /.*\z/ not?

If we expand that scheme, why does /.?.?\z/ match, and /.*.?\z/ not?

In all cases I'd expect .? and .* to be reduced to the empty string - why doesn't it happen?

  • Comment on Re^4: Strange regex to test for newlines: /.*\z/

Replies are listed 'Best First'.
Re^5: Strange regex to test for newlines: /.*\z/
by shmem (Chancellor) on May 21, 2007 at 15:47 UTC
    Now I'm confused as well, my mental model doesn't seem to fit (at least not everywhere :-)

    Maybe demerphq could tell?

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

      avar confirms this bug still exists in blead, so ill give it a look when i get a chance. right cant say more right now as i injured my arm today and hacking one handed is no fun. (yes im fine, or so the xrays said)

      ---
      $world=~s/war/peace/g

        as i injured my arm today and hacking one handed is no fun
        oh, then get well soon.
        i have a special keyboard for one-handed hackers that i could borrow you if you like ;-)