\Z in regular expressions #86

Closed
atombender opened this Issue Mar 24, 2012 · 1 comment

Comments

Projects
None yet
3 participants
@atombender

\Z is actually equivalent to:

/\n?\z/ 

In other words, it matches a line ending at the end of the string. Not necessarily what you want, although probably rarely harmful.

The correct regexp syntax to match the absolute end of the string is \z.

@JuanitoFatas

This comment has been minimized.

Show comment
Hide comment
@JuanitoFatas

JuanitoFatas Apr 1, 2012

Contributor

If you want to match the whole string use: \A and \z.

+ 1

Contributor

JuanitoFatas commented Apr 1, 2012

If you want to match the whole string use: \A and \z.

+ 1

@bbatsov bbatsov closed this in 32cb8c6 Apr 9, 2012

marocchino pushed a commit to marocchino/ruby-style-guide that referenced this issue Aug 11, 2015

shyouhei pushed a commit to shyouhei/ruby-style-guide that referenced this issue Nov 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment