Parse dictionary looking for a specific string
<p>I'm writing a python script to make an API call to our Cisco ASA firewall and the information returned from the firewall is placed into a dictionary. I then need to parse through this dictionary looking for a specific string. The problem is, there's 1 key and what looks to be one large value. I've inserted an example of the output I receive from the firewall. </p>

<blockquote>
  <p>{u'response': [u'object-group network
  ng-enc-incoming-ftp-outside\nnetwork-object 1.1.1.1 255.255.255.128\n
  network-object host 2.2.2.2\n network-object host 3.3.3.3\n
  network-object host 4.4.4.4\n network-object host 5.5.5.5]}</p>
</blockquote>

<p>Ideally, I would like to search this output looking for a specific IP and if that IP was present, present a message indicating as much. I can't seem to find a good way to parse through a really long value looking for a specific text string.  </p>

<p>Extract all IP and then you can search for a particular IP address in the list or loop through all of them. Alternately you can search directly in the string as @DeepSpace says</p>

<pre><code>import re

d = {u'response': [u'object-group network ng-enc-incoming-ftp-outside\n network-object 1.1.1.1 255.255.255.128\n network-object host 2.2.2.2\n network-object host 3.3.3.3\n network-object host 4.4.4.4\n network-object host 5.5.5.5']}

ip = re.findall(r'(\d+\.\d+\.\d+\.\d+)', d['response'][0])  

&gt;&gt;&gt; [u'1.1.1.1', u'255.255.255.128', u'2.2.2.2', u'3.3.3.3', u'4.4.4.4', u'5.5.5.5']

'1.1.1.1' in ip
&gt;&gt;&gt; True

'1.1.1.2' in ip
&gt;&gt;&gt; False
</code></pre>

python dictionary networking