Don't replace version numbers of *partial* matches
See original GitHub issueGiven a setup.py
file containing those two lines:
if pkg_resources.get_distribution("setuptools").version < "40.1.1":
# ... other lines
version="0.1.1",
If you bump the version (the patch for example), it will modify 40.1.1
to 40.1.2
. This is because it’s a simple replace using the current version. It probably should use a regex to find the version the file. The only work around I found was to the change the search to include the double quotes.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Regex to not match partial sequences, but match full ones
I'm trying to match and replace full escape sequences like ' but not partial, like 39 , since 39 is not actually in...
Read more >Substitutions in Regular Expressions | Microsoft Learn
Make substitutions to replace matched text using regular expressions in .NET. Substitutions are language elements recognized only within ...
Read more >Excel IF statement for partial text match (wildcard) - Ablebits
The tutorial shows how to make Excel IF statement with wildcard text and get it to work for partial matches.
Read more >perlrequick - Perl regular expressions quick start
A failed match or changing the target string resets the position. If you don't want the position reset after failure to match, add...
Read more >Regular Expression Examples - the Tcler's Wiki!
Janos Holanyi: I would really need to build up a re that would match one line and ... If you don't mind a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not working on a fix, but here is a unit test which demonstrates the problem.
https://github.com/florisla/bump2version/tree/dont-replace-partial-matches
This is not very trivial to fix since the current
utils.ConfiguredFile.replace()
does not use regular expressions (re.sub
). It’s simply serializing thesearch
andreplace
text, and doingstr.replace
on the whole file content.