I am trying to write a regex that grabs blocks of whitespace from either side of a string. I can get the beginning, but I can't seem to grab the end block.
s = ' This is a string with whitespace on either side '
strip_regex = re.compile(r'(\s+)(.*)(something to grab end block)')
mo = strip_regex.findall(s)
What I get as an output is this:
[(' ', 'This is a string with whitespace on either side ')]
I have played around with that to do at the end, and the best I can get is one whitespace but I can never just grab the string until the end of 'side'. I don't want to use the characters in side because I want the regex to work with any string surrounded by whitespace. I am pretty sure that it's because I am using the (.*) which is just grabbing everything after the first whitespace block. But can't figure out how to make it stop before the end whitespace block.
Thanks for any help :)