[Tutor] re module help
bugcy013 at gmail.com
Mon Jan 9 10:17:46 CET 2012
I have created regular expression with os modules, I have created file
sdptool to match the regular expression pattern, will print the result.
I want without creating file how to get required output, I tried but i
didn't get output correctly, over stream.
cmd = "sdptool -i hci0 search OPUSH > sdptool"
fp = os.popen(cmd)
results = 
l = open("sdptool").read()
pattern = r"^Searching for OPUSH on (\w\w(:\w\w)+).*?Channel: (\d+)"
r = re.compile(pattern, flags=re.MULTILINE|re.DOTALL)
for match in r.finditer(l):
g = match.groups()
## output [('00:15:83:3D:0A:57', 'phone', '1')]
please guide me. with out file creating, to archive required output.
Did I learn something today? If not, I wasted it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor