I am using python, and this regexp doesn’t match, and I don’t understand why.
string = "15++12"
if re.match("[-+*/][-+*/]+",string):
# raise an error here
I am trying to raise an error, if one or more of “-“,”+”,”*”,”/” follows another one of those.
Use
re.search()asre.match()only searches at the beginning of the string:Also, this could be simplified to:
as the
{2,}operator searches for two or more of the previous class.