I am new to python and want to run a code in Python.
Code that I have written is
#!/usr/bin/python
import sys
import re
for line in sys.stdin:
results = re.search('ipAddress=([^&]*])', line)
if len(results.group(1)) != 0:
print results.group(1)
Requirement is finding IP address in a string.String will be something like this
blah....ipAddress=173.110.208.118&deviceId
Output: 173.110.208.118
Please let me know what I am doing wrong..
I think you've got one ] too many there. Try
results = re.search('ipAddress=([^&]*)', line)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With