jeudi 14 juillet 2016

Python regex match numbers or nothing

I have strings:

1st one

-1,1N,0.0464128206,0.1106913625,-0.0261445305

2nd one

-1,1N,0.,0.,0.

It can be done manually to the

 -1,1N,0.0,0.0,0.0

but I am trying to make script working without any editing

My RegEx is

d,d\[A-Z],[-]?d+.d+,[-]?d+.d+,[-]?d+.d+

How to make RegEx work on d+ or just skip it if is not present?

UPD: I want to make RegEx which will get true for both strings. How to make this part 'd+.d+' to skip second d+ if it is absent? [d+]? is not working.

Aucun commentaire:

Enregistrer un commentaire