<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://united-coders.com"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>united-coders.com - rexexp</title>
 <link>http://united-coders.com/taxonomy/term/88/0</link>
 <description></description>
 <language>en</language>
<item>
 <title>IP address regex example - not in java</title>
 <link>http://united-coders.com/christian-harms/ip-address-regex-example-not-in-java</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;Finding an IP address in text or string with python is a simpler task than in &lt;a href=&quot;http://united-coders.com/nico-heid/regular-expressions-in-java&quot;&gt;java&lt;/a&gt;. Only the regex is not shorter than in the java regex example!&lt;/p&gt;
&lt;p&gt;First an example with python: build a RegExp-Object for faster matching and than loop over the result iterator.&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;div class=&quot;python geshifilter-python&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;logText = &amp;nbsp;&lt;span style=&quot;color: #483d8b;&quot;&gt;&#039;asdfesgewg 215.2.125.32 alkejo 234 oij8982jldkja.lkjwech . 24.33.125.234 kadfjeladfjeladkj&#039;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;bytePattern = &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;([01]?&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\d&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\d&lt;/span&gt;?|2[0-4]&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\d&lt;/span&gt;|25[0-5])&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;regObj = &lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt;.&lt;span style=&quot;color: #008000;&quot;&gt;compile&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\.&lt;/span&gt;&amp;quot;&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;bytePattern&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; match &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; regObj.&lt;span style=&quot;color: black;&quot;&gt;finditer&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;logText&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; match.&lt;span style=&quot;color: black;&quot;&gt;group&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;A regex like &lt;code&gt;/\d+\.\d+\.\d+\.\d+/&lt;/code&gt; wont work, because there match &quot;999.999.111.000&quot; too. But for the usage in python - that is it! Using a regular expression is more native in python than in java. Or in javascript or in perl or &lt;a href=&quot;http://www.tipsntracks.com/112/regular-expressions-ip-address-validation-with-net.html&quot;&gt;asp.net&lt;/a&gt;... &lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/ip-address-regex-example-not-in-java&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/ip-address-regex-example-not-in-java&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/ip-address-regex-example-not-in-java&quot; dc:title=&quot;IP address regex example - not in java&quot; trackback:ping=&quot;http://united-coders.com/trackback/38&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-7375&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/ip-address-regex-example-not-in-java#comments</comments>
 <category domain="http://united-coders.com/category/tags/ip-address">ip address</category>
 <category domain="http://united-coders.com/category/tags/javascript">javascript</category>
 <category domain="http://united-coders.com/category/tags/perl">perl</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <category domain="http://united-coders.com/category/tags/rexexp">rexexp</category>
 <pubDate>Thu, 17 Sep 2009 22:45:21 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">38 at http://united-coders.com</guid>
</item>
</channel>
</rss>


