I have the following code:
def commandType(self):
import re
print self.cmds[self.counter]
if re.match("@",self.cmds[self.counter]):
return Parser.A_COMMAND
elif re.match('(',self.cmds[self.counter]):
return Parser.L_COMMAND
else:
return Parser.C_COMMAND
and on this line: elif re.match('(',self.cmds[self.counter]):
I’m getting an error.
What am I doing wrong?
Parentheses have special meaning in regular expressions. You can escape the paren but you really do not need a regex at all for this problem: