Skip to content

Commit

Permalink
The \A and \z anchors are allowed in regexen
Browse files Browse the repository at this point in the history
Henrik explained that the wrong note in the spec came from a weird and probably
unwanted bit of code in the lexer that would sometimes strip those anchors
out... but only if they were occurring in positions where they'd never match any
string. He thinks either we were trying to "help," or we might have been working
around a bug in some ancient Ruby.
  • Loading branch information
nfagerlund committed Apr 9, 2015
1 parent ef3ddb2 commit 7f705d0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions future_regex.pp
@@ -0,0 +1,14 @@
notice("my string" =~ /^my string$/) # true
notice("my string" =~ /\Amy string\z/) # true
notice("my string" =~ /\Amy stringgg\z/) # false
# .... so the bit about \A and \z being disallowed at https://github.com/puppetlabs/puppet-specifications/blob/master/language/lexical_structure.md#regular-expressions seems to not be true? What would definitively prove this?
notice("my string\nhey second line" =~ /\Amy string\Z/) # false
notice("my string\nhey second line" =~ /^my string$/) # true, So, ok....
notice("my string\n" =~ /\Amy string\z/) # false
notice("my string\n" =~ /\Amy string\Z/) # true
notice("hey\nmy string\n" =~ /\Amy string\Z/) # false

# this is looking like that's not the case at all.

0 comments on commit 7f705d0

Please sign in to comment.