<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Splitting a string in Velocity in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/splitting-a-string-in-velocity/m-p/4845525#M8776</link>
    <description>&lt;P&gt;Something like?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#set ($networks = ${networks})
#set ($octets = $networks.split('\,'))
#set ($masks = [])

#foreach ($net in $octets)
  #set ($mask = $net.split('/')[1])
  #set ($masks.add($mask))
#end

#foreach ($mask in $masks)
  $mask
#end&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;&lt;SPAN&gt;inputted string is &lt;/SPAN&gt;192.168.0.0/24,172.16.0.0/16&lt;SPAN&gt;, the code will print the following to the console:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;24
16&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 May 2023 15:42:11 GMT</pubDate>
    <dc:creator>bigevilbeard</dc:creator>
    <dc:date>2023-05-30T15:42:11Z</dc:date>
    <item>
      <title>Splitting a string in Velocity</title>
      <link>https://community.cisco.com/t5/network-platform-api/splitting-a-string-in-velocity/m-p/4845484#M8775</link>
      <description>&lt;P&gt;I'm attempting to split a user inputted string that is representing a list of comma separated IP addresses in CIDR notation. In order to determine a wildcard mask later in the script.&lt;/P&gt;&lt;P&gt;eg. 192.168.0.0/24,172.16.0.0/16&lt;/P&gt;&lt;P&gt;#set ($networks = ${networks})&lt;BR /&gt;#set ($octets =$networks.split('\,'))&lt;BR /&gt;#set ($mask = $octets)&lt;/P&gt;&lt;P&gt;#foreach ($net in $mask)&lt;BR /&gt;$net&lt;BR /&gt;#end&lt;/P&gt;&lt;P&gt;This outputs:&lt;/P&gt;&lt;P&gt;192.168.0.0/24&lt;/P&gt;&lt;P&gt;172.16.0.0/16&lt;/P&gt;&lt;P&gt;I'm using this currently to create a prefix list which works as expected. However i'd like to also create an ACL from the list which would require determining the Wildcard Mask.&lt;/P&gt;&lt;P&gt;So what I would like to achieve is a way of returning just the list of masks e.g.&lt;/P&gt;&lt;P&gt;24&lt;/P&gt;&lt;P&gt;16&lt;/P&gt;&lt;P&gt;Any tips on how can i achieve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 14:53:16 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/splitting-a-string-in-velocity/m-p/4845484#M8775</guid>
      <dc:creator>glsparks</dc:creator>
      <dc:date>2023-05-30T14:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string in Velocity</title>
      <link>https://community.cisco.com/t5/network-platform-api/splitting-a-string-in-velocity/m-p/4845525#M8776</link>
      <description>&lt;P&gt;Something like?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#set ($networks = ${networks})
#set ($octets = $networks.split('\,'))
#set ($masks = [])

#foreach ($net in $octets)
  #set ($mask = $net.split('/')[1])
  #set ($masks.add($mask))
#end

#foreach ($mask in $masks)
  $mask
#end&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;&lt;SPAN&gt;inputted string is &lt;/SPAN&gt;192.168.0.0/24,172.16.0.0/16&lt;SPAN&gt;, the code will print the following to the console:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;24
16&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 15:42:11 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/splitting-a-string-in-velocity/m-p/4845525#M8776</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2023-05-30T15:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string in Velocity</title>
      <link>https://community.cisco.com/t5/network-platform-api/splitting-a-string-in-velocity/m-p/4846140#M8777</link>
      <description>&lt;P&gt;Perfect well almost perfect. I had to add this to get it to work. Else it just through a syntax error. But many thanks really helped me out.&lt;/P&gt;&lt;P&gt;#set ($networks = ${networks})&lt;BR /&gt;#set ($octets = $networks.split('\,'))&lt;BR /&gt;#set ($masks = [])&lt;/P&gt;&lt;P&gt;#foreach ($net in $octets)&lt;BR /&gt;#set ($mask = $net.split('/')[1])&lt;BR /&gt;#set (&lt;STRONG&gt;$foo&lt;/STRONG&gt; = $masks.add($mask))&lt;BR /&gt;#end&lt;BR /&gt;#foreach ($mask in $masks) $mask&lt;BR /&gt;#end&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 07:20:47 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/splitting-a-string-in-velocity/m-p/4846140#M8777</guid>
      <dc:creator>glsparks</dc:creator>
      <dc:date>2023-05-31T07:20:47Z</dc:date>
    </item>
  </channel>
</rss>

