I have a function that should return a certain number from a mysql table. The number is filtered out of the string using regex like so: ^\((\d*),\)$. The original string is (36,) and the regex should change it to this: 36. But i still get (36,)!
class db:
con = mysql.connect()
cur = con.cursor()
def fo(self, query):
self.cur.execute(query)
return re.search('^\((\d*),\)$',
str(self.cur.fetchone())).group(0)
and further on I call the function:
return db().fo('SELECT id FROM `GIP-Schema`.user WHERE name = \'{0}\''.format(name))
.group(0)->.group(1)group(1)or change regex to^\(?:(\d*),\)$.group(0)is the whole matched expression.