Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40813 > unrolled thread

Re: Insert comma in number?

Started byJohn Posner <jjposner@optimum.net>
First post2013-03-07 14:06 -0500
Last post2013-03-07 14:06 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Insert comma in number? John Posner <jjposner@optimum.net> - 2013-03-07 14:06 -0500

#40813 — Re: Insert comma in number?

FromJohn Posner <jjposner@optimum.net>
Date2013-03-07 14:06 -0500
SubjectRe: Insert comma in number?
Message-ID<mailman.3047.1362684983.2939.python-list@python.org>
Peter Otten wrote:

> Last not least there's the option to employ locale-aware formatting:


Not quite last ... there's the mind-bending regular expression route:

   import re
   re.sub(r"(?<=\d)(?=(\d\d\d)+$)", ",", "12345678")   # 12,345,678
   re.sub(r"(?<=\d)(?=(\d\d\d)+$)", ",", "-54321")     # -54,321

-John


[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web