I have a function:
find = re.compile(ur"\s+(Word)\s+", flags = re.U) text = find.sub('\1', text)
and I want to find a template like this " Word " (with a prefix / suffix) and replace it with "Word" (without these spaces). in ruby, I did this before with something like this:
text.gsub('\s+(Word)\s+', '\1')
Edit: I mean, I need to change these spaces with a new line or something else depending on the situation.
source share