Ask Your Question
1

Split ipaddress on class

asked 2015-09-04 06:39:43 -0500

163 gravatar image

updated 2015-09-04 13:09:52 -0500

GregLarkin gravatar image

I am trying use the first octet of ipaddress, but I can get the array with split function

$ips = split($::ipaddress, '.')
$octet = $ips[0]

case $octet {
  '192': { notify {"####################### ok  $octet ###################":} }
  default: { notify {"####################### don't work $octet ###################":} }
}

The result is:

"####################### don't work  ###################"
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2015-09-04 13:11:15 -0500

GregLarkin gravatar image

The 2nd parameter to the split function is a regular expression. The dot (".") is the equivalent of "any character" in regular expressions. In order to split on a literal dot character, you need to escape it like so:

 $ips = split($::ipaddress, '\.')
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-09-04 06:39:43 -0500

Seen: 358 times

Last updated: Sep 04 '15