my code here i am trying to get the "something-try-composition-library" and version "0.29.2"
import re
mystr = "something-try-composition-library version v0.29.2"
new_str = '-'.join(mystr.rsplit('v', 1))
final_str = re.split('\\ version \\b',new_str)
but when i am printing the final_str it is returning
['something-try-composition-library version -0.29.2']
instead of
['something-try-composition-library', '-0.29.2']
the problem seems to be with the new_str as when i pass mystr it is working fine but yes with the extra v with the version number.
my question is how to convert the output of new_str as raw string. or if any one have any easy and simple way to get this output
['something-try-composition-library', '-0.29.2']
will also be great help.
Thanks.
CodePudding user response:
This is a very specific solution, but for your string it works:
mystr = "something-try-composition-library version v0.29.2"
final_str = '-'.join(mystr.rsplit('v', 1)).rsplit(' version ')
output = ['something-try-composition-library', '-0.29.2']