{% highlight Python %}
import re
class Demo:
def checkIP(self,inputSeq):
patternIP = '^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$'
if re.search(patternIP,inputSeq):
return 1
else:
return 0
if __name__ == '__main__':
demo = Demo()
ip = '10.19.10.2'
print demo.checkIP(ip)
{% endhighlight %}
网友评论