On 12/5/14 3:16 PM, Lori Cho wrote:
I have two variables and I want to compare them to each other.  However,
the regex doesn't return true, because it seems to treat the variable in
the // as a literal.

Something like this:

$variable1 = 'foo'
$variable2 = 'foobar'

if($variable2 =~ /$variable1/) {
         notify {"it works":}
} else {
         notify {"regex did not work":}
}

root@test-slincsplunk1101r(~)# puppet apply /srv/tmp/test.pp
notice: regex did not work
notice: /Stage[main]//Notify[regex did not work]/message: defined
'message' as 'regex did not work'


How can I do this?

The docs say it's not available. https://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#regular-expressions

"Alternate forms of regex quoting are not allowed and Ruby-style variable interpolation is not available."

Ramin


--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/54825119.7020801%40badapple.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to