Search code examples
pythonpython-re

Choosing numbers and full points from a string


I wrote the following code to choose the numbers from a string. I only get integers and I'd like to get the decimals too.

def vreplace_chars(third): 
                vlist_of_numbers = re.findall(r'\d+',third)
                vresult_number = '---'.join(vlist_of_numbers)
                return vresult_number
            number=vreplace_chars(imgchar)


Solution

  • Change a regex to optionally include decimal part \d+(?:.\d+)?