![]() |
|
|
+ Search |
![]()
|
Jul 18th, 2000 21:16
unknown unknown, Wolfgang Strobl
Problem:
I am finding it difficult to match the ip address in the
following line using re module.
" inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0"
Solution:
>>> import re
>>> s=" inet addr:192.168.0.1 Bcast:192.168.0.255
Mask:255.255.255.0"
>>> p=re.compile('\s+inet addr:(\d+\.\d+\.\d+\.\d+)\s+.*')
>>> p.match(s).groups()
('192.168.0.1',)
>>>