Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Converting an output to raw string in python

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

['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.

>Solution :

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']
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading