I want to print first, second and third matched group in an expression. Here is the details.
Regex Pattern = "(\d+)"
Expression = "1123-xxx-abcd-45-tsvt-35-pwrst-99-xql"
I used Pythex, https://pythex.org/?regex=(%5Cd%2B)&test_string=1123-xxx-abcd-45-tsvt-35-pwrst-99-xql&ignorecase=0&multiline=0&dotall=0&verbose=0 It is working perfectly find and it displays all the captured groups.
But it is not working in python code. I provide below the python code, I am unable to find the problem.
import re
class Test3:
def printAllGroups(self):
regexPattern = r"(\d+)"
text = "1123-xxx-abcd-45-tsvt-35-pwrst-99-xql"
matcher = re.compile(regexPattern, flags=re.IGNORECASE)
matchValue = matcher.match(text);
if matchValue:
print("First group : ", matchValue.group(1))
print("Second group : ", matchValue.group(2))
print("Third group : ", matchValue.group(2))
if __name__ == '__main__':
test3 = Test3()
test3.printAllGroups()
Please help me solve this problem, I am new to Python.