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

Match last 2 number in a string separated by dot

Which regex would fit better to extract the last 2 numbers separated by dot

e.g.

abc.98.76.xyz12.34 -> 12.34
qwer12.34.ty.98.76 -> 98.76

I tried \d+(?!\d+)\.\d+(?!\d+)$ but not sure if it’s the best option.

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

>Solution :

Possible solution is the following:

(\d+\.\d+)$

See explanation at regex101

if you need to specify exact qty of numbers:

(\d{2}\.\d{2})$

Where:
\d - any digit
+ - one o more characters
\. - dot
{2} - exactly two characters
$ - end of string
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