The following regular expression can be used to insert commas as thousands delimiter. The pattern was taken from the http://www.dlang.org web site.