Match integer values from end of string until second dot

I have following string GA1.2.4451363243.9414195136 and I want to match 4451363243.9414195136 using regular expression for python.

How do I got about it?

>Solution :

The following regex ([0-9]+.[0-9]+)$ matches the expected part of the example. Note that more specific solutions may arise as you provide more details, restrictions, etc. regarding the part to be matched:

>>> import re
>>> data = "GA1.2.4451363243.941419513"
>>> re.findall(r"([0-9]+.[0-9]+)$", data)
['4451363243.941419513']

It requests the matched part to be made of:

  • digit(s)
  • dot
  • digit(s)
  • end of line.

Leave a Reply