Unbalanced parenthesis python
python, regex
Solution
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:
def commandType(self):
print self.cmds[self.counter]
if '@' in self.cmds[self.counter]):
return Parser.A_COMMAND
elif '(' in self.cmds[self.counter]:
return Parser.L_COMMAND
else:
return Parser.C_COMMAND
Problem
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?