I need to write a strip function using regex.
This is my current code:
import re
def makestringstripfun(text):
stripStringRegex = re.compile(r'(^.*?)(\w+)( +\w+)*(\s|.*?)$')
match = stripStringRegex.search(text)
print(match)
print('Enter the string:')
text = input()
makestringstripfun(text)
I want to output the entire string, whatever I enter. Right now, if I enter the following text:
smith john go home your shift getting over in the 30 minute later then why you here
the output of my code is:
<_sre.SRE_Match object; span=(0, 84), match='smith john go home your shift getting over in t>