demo_regex_match_string.py:
import re #The string property returns the search string: txt = "The rain in Spain" x = re.search(r"\bS\w+", txt) print(x.string)
C:\Users\My Name>python demo_regex_match_string.py
The rain in Spain