I'm trying to take information from a site, read it in line by line and only take the lines that start with two digits, a semicolon, two digits a semicolon and two more digits (i.e. 00:00:00). Matches are exported to another file.
I am getting a syntax error for the semicolons in my regex.
#!/usr/bin/python
import urllib2
import re
#imported urllib to collect the data. imported re for regular expressions to test format.
#creating our output file
f=open("output.txt", "r+")
#opening a file like object using urllib
webpage= urllib2.open("https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf")
#string used to store the output
str=""
#string used to store current line
temp=""
#add while loop to read in that data. line by line.
temp=webpage.readline()
if temp.re.search([0-9][0-9]:[0-9][0-9]:[0-9][0-9]):
str.concat(temp)
temp=""
"") around the regex."[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"works just fine. Colons are only (part of) an operator in the(?: ... )syntax.codef=open("output.txt", "r+") to w+ however, now I get the error "AttributeError: 'str' object has no attribute 're' from the if line.