Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A question about regular expressions (addition to the tutorial)

44 views
Skip to first unread message

Arjen Markus

unread,
Aug 8, 2017, 3:41:28 AM8/8/17
to
Hello,

I was contemplating an addition to the online Tcl tutorial about regular expressions and came up with the following idea: find literal numbers in text and group the digits. Like "100000" -> "100,000" and "1000000" -> "1,000,000".

I could not think of a regular expression to do that. Maybe I am overlooking an obvious solution, but does anybody have an idea?

Regards,

Arjen

Rich

unread,
Aug 8, 2017, 6:41:47 AM8/8/17
to
You might try this Wiki page: http://wiki.tcl-lang.org/5000

Arjen Markus

unread,
Aug 8, 2017, 6:53:16 AM8/8/17
to
On Tuesday, August 8, 2017 at 12:41:47 PM UTC+2, Rich wrote:

>
> You might try this Wiki page: http://wiki.tcl-lang.org/5000

Ah, thanks, I realised that it required some advanced feature but I could not imagine what exactly. This is actually perfect for what I want.

Regards,

Arjen

stefan

unread,
Aug 8, 2017, 7:13:46 AM8/8/17
to
FWIW, this is what I came up with:

join [regexp -inline -all {\d{1,3}(?=(\d{3})*$)} {1000000000}] ,

Figured this is just a variant from the one solution archived at the above Wiki page.

Stefan

Arjen Markus

unread,
Aug 8, 2017, 7:33:01 AM8/8/17
to
It will be a good exercise to explain it :)

Regards,

Arjen
0 new messages