HomeSoftware Heritage

Search for newlines at end of string, not at end of line

Description

Search for newlines at end of string, not at end of line

$ matches both end of string and end of line.
so /\n$/ matches \n\n anywhere in the string.
while /\n\Z/ only matches \n at the end of the string.

irb(main):021:0> "a\n\nb" =~ /\n$/
=> 1
irb(main):022:0> "a\n\nb" =~ /\n\Z/
=> nil
irb(main):023:0> "a\n\nb\n" =~ /\n$/
=> 1
irb(main):024:0> "a\n\nb\n" =~ /\n\Z/
=> 4

Details

Provenance
Simon Peeters <simon.peeters@ugent.be>Authored on Jan 3 2020, 4:21 PM
GitHub <noreply@github.com>Committed on Jan 3 2020, 4:21 PM
olasdPushed on Jan 13 2020, 2:13 PM
Parents
rSPCATbe2f3a333438: Merge pull request #619 from puppetlabs/pdksync_travis-updates
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rSPCAT8e2a8283cf72: Search for newlines at end of string, not at end of line (authored by Simon Peeters <simon.peeters@ugent.be>).Jan 3 2020, 4:21 PM