The string looks like this: (\n used to break the line)
MySQL-vm
Version 1.0.1
WARNING:: NEVER EDIT/DELETE THIS SECTION
What I want is only 1.0.1 .
I am trying re.search(r"Version+'([^']*)'", my_string, re.M).group(1) but it is not working.
re.findall(r'\d+', version) is giving me an array of the numbers which again I have to append.
How can I improve the regex ?
"Version+"means matchV-e-r-s-i-oand then one or morens.none or more times.re.search(r"Version+'([^']*)'", my_string, re.M).group(1). What is the intended purpose of the's? Based on how it is constructed, it looks as though you are quite deliberately looking for a single-quoted string (i.e.: a single-quote, some not-single-quote characters, and then a closing single-quote). Now, look carefully at the input: does the data you want actually look like that? I don't see quotes around the1.0.1, therefore there is no reason to look for them. Why was this not closed as an obvious typo at the time?