Extracting a pattern from a string

Recall that the search() method returns a match object if it locates the pattern in the search string. If you save the match object to a variable, you can use the group() function of the match object to retrieve the first occurrence of the pattern in the search string:

....
match = number_then_word.search("**** 1234 abcd ****")
print(match.group())
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset