R.N.G
R.N.G

Reputation: 31

How to string split numbers in python

This is what I have, but I know it is incorrect and I'm not sure what to change

print '0.4066145E-07-0.3677403'.split('E+(\-\d{2})', 1 )

I'm looking to get:

['0.4066145E-07','-0.3677403']

or more generally I just want to split up these numbers.

['######E-##','#########']

Also what if there is an exponent in the second number?

['######E-##','#######E-##']

Upvotes: 2

Views: 96

Answers (1)

m.cekiera
m.cekiera

Reputation: 5395

You can try with:

(?<=E-\d\d)(?=-\d+.)

DEMO

Upvotes: 2

Related Questions