Aditya Kuls Aditya Kuls - 1 month ago 4x
Python Question

How to split a string in python based on dots, ignoring decimal values?

I have the following string:

s = 'This .is sparta 1.2 version. Please check.'

I want to split it based on dots, while ignoring decimal figures.
So, Required Output :

['This ','is sparta 1.2 version','Please check']

I tried following:


The output I am getting is:

['This ', None, 'is sparta 1.2 version', '', ' Please check', None, '']

Why am I getting None and empty strings here? I just want the split strings, ie.

['This ','is sparta 1.2 version','Please check']

Please suggest the rectification here.


Try splitting on


It makes sure the dot isn't preceded, nor followed, by a digit.

See it here at regex101.