regex - Python regular expression remove period from number at end of sentence -


If I have a string like: "I like 3.142 and 2 numbers."

And I want to remove the period after 2 but not one in 3.142, how do I do it? In fact, how do I check that there is no number after the duration of the number after a period and how do I remove that period? Thank you.

  & gt; & Gt; & Gt; Import re & gt; & Gt; & Gt; S = "I have always been. 3.142, 5., 6.12 and 2. Lalla." & Gt; & Gt; & Gt; Re.sub ('((\ d +) [\.]) (?! ([\ D] +),' \ g> 2 & gt; ', s)' I always Like number 3.142, 5, 6.12 and 2 red. ' 

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -