import res = "shivam gupta"m = re.match(r"shivam\s+(\w+)$", s)if m: # if the pattern matches print(m.group(1)) # print only Group 1 contents
Standard input is empty
gupta
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!