Open wenkokke opened 2 years ago
It might be possible, I'm not sure. The thing about the pattern syntax is, that it is used both for search and also for the replacement string. For ^
and $
this worked well, as we can generate the replacement string by just stripping them off.
The current logic works completely independently of the content to which the replacement is applied.
# remove regex chars
result = result.replace(r"^", r"")
result = result.replace(r"$", r"")
# unescape braces
result = result.replace(r"\[", r"[")
result = result.replace(r"\]", r"]")
for part, part_value in used_parts:
result = result.replace(part, part_value)
So, in order to implement this, the logic would need to change so that
\s+
in a capture group syntax (\s+)
and then extracting it from a regex match object.It would be a good idea to also validate every generated replacement, by making sure the search pattern matches it. Otherwise I'd be worried that we replace a version string with something that won't be matched in a later update.
Overall this does not seem to be worth it for me to put in the effort, but I'll be happy to give feedback on and accept a PR.
Code formatters may sometimes insert whitespace, e.g., to align columns in a configuration file.
Would it be possible to allow, e.g.,
\s+
in the bumpver configuration files, to match variable amounts of whitespace, similar to the addition of^
and$
?