Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: How to match last character of string, even if it happens to be a newline?

by Allasso (Monk)
on May 12, 2019 at 15:17 UTC ( #1233649=note: print w/replies, xml ) Need Help??


in reply to Re: How to match last character of string, even if it happens to be a newline?
in thread How to match last character of string, even if it happens to be a newline?

Using \z, I don't seem to need multiline, simply m@(.)\z@s
  • Comment on Re^2: How to match last character of string, even if it happens to be a newline?
  • Download Code

Replies are listed 'Best First'.
Re^3: How to match last character of string, even if it happens to be a newline?
by AnomalousMonk (Chancellor) on May 12, 2019 at 15:40 UTC
    Using \z, I don't seem to need multiline ...

    That's because  \z is always the absolute end-of-string anchor; no modifiers apply. I always use  \A \z \Z because they have invariant behavior. For the same reason, I nail down the  ^ $ operators by always using the  /m modifier. (I then use the  ^ $ operators only with newlines embedded within a string.)


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2019-06-19 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (83 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!