From 7f705d0d6c7684c3750ccda0afba186e2290fb2f Mon Sep 17 00:00:00 2001 From: Nick Fagerlund Date: Thu, 9 Apr 2015 11:31:19 -0700 Subject: [PATCH] The \A and \z anchors are allowed in regexen 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. --- future_regex.pp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 future_regex.pp diff --git a/future_regex.pp b/future_regex.pp new file mode 100644 index 0000000..ebd4f3c --- /dev/null +++ b/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. + + +