Skip to content

\Z in regular expressions #86

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

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

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

+ 1

@bbatsov bbatsov closed this in 32cb8c6 Apr 9, 2012
@marocchino marocchino pushed a commit to marocchino/ruby-style-guide that referenced this issue Aug 11, 2015
Bozhidar Batsov fixed #86 - \z instead of \Z for matching the absolute end of a string 9cf8dc4
@shyouhei shyouhei pushed a commit to shyouhei/ruby-style-guide that referenced this issue Nov 11, 2015
Bozhidar Batsov fixed #86 - \z instead of \Z for matching the absolute end of a string 977b632
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.