I am trying to extract the name stored in the variable below. I am trying to extract using regular expression but I am getting a invalid syntax error.
import re
var = 'Thomas/Male/'
output = re.search('([\w.-]+)/([\w.-]+)', var)
if output:
print output.group(1)
Expected output 1 : Thomas
Expected output 2 : Male
Could anyone help on this. Thanks
print output.group(1)in Python 3. Also, you refer to a variablematchwithout creating it first.