Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

A question about regular expressions (addition to the tutorial)

已查看 44 次
跳至第一个未读帖子

Arjen Markus

未读,
2017年8月8日 03:41:282017/8/8
收件人
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

未读,
2017年8月8日 06:41:472017/8/8
收件人
You might try this Wiki page: http://wiki.tcl-lang.org/5000

Arjen Markus

未读,
2017年8月8日 06:53:162017/8/8
收件人
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

未读,
2017年8月8日 07:13:462017/8/8
收件人
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

未读,
2017年8月8日 07:33:012017/8/8
收件人
It will be a good exercise to explain it :)

Regards,

Arjen
0 个新帖子