better way to find pattern in string? <p>I have two strings from which I want to extract IPs.</p> <p>These are:</p> <pre><code>a = """+CGCONTRDP: 1,0,"open.internet","100.80.54.162.255.255.255.255","100.80.54.162","8.8.8.8 ","62.40.32.33","0.0.0.0","0.0.0.0",0 OK """ b = """+UIPADDR: 1,"usb0:0","100.80.54.93","255.255.255.255","","" OK """ </code></pre> <p>From the first I want <code>100.80.54.162</code> and the second I want <code>100.80.54.162</code>. Now obviously lengths of numbers in an IP changes. For the moment I am spitting on <code>","</code> and finding the numbers before the first 4 <code>.</code>'s. What is a better way to do this as it seems dirty, perhaps the first occurrence of digits.digits.digits.digits and stopping at the next non digit character, a pattern looking for that? How would you do it?</p>