python - pythonic way to write the code for search and replace string -


this question has answer here:

i have written code search , replace string in make command per user input

make language='english' id=234 version=v1 path='/bin'

in above code searched version=v1 , replace version version=v2

import re strings = "make language='english' id=234 version=v1 path='/bin'" search_pattern= re.search('version=(.*?)\s', strings) old_str = search_pattern.group(1) print test.replace(old_str, "v2") 

can me write above code in pythonic way or other way write above code

it's easy if use str.replace

string = "make language='english' id=234 version=v1 path='/bin'" string = string.replace("version=v1", "version=v2") 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -