lc_sepfmt (private)
lc_sepfmt num [ grouping ] [ sep ] [ num_re ]
Defined in packages/acs-lang/tcl/localization-procs.tcl
Called by lc_numeric and lc_monetary.
Takes a grouping specifier and inserts the given separator into the string. Given a separator of : and a number of 123456789 it returns:
grouping Formatted Value {3 -1} 123456:789 {3} 123:456:789 {3 2 -1} 1234:56:789 {3 2} 12:34:56:789 {-1} 123456789
- Parameters:
- num (required)
- Number
- grouping (optional, defaults to
"3"
)- Grouping specifier
- sep (optional, defaults to
","
)- Thousands separator
- num_re (optional, defaults to
"[0-9]"
)- Regular expression for valid numbers
- Returns:
- Number formatted with thousand separator
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: # with empty separator or grouping string we behave # posixly if {$grouping eq "" || $sep eq "" } { return $num } # we need to sanitize the subspec regsub -all -- "(\[&\\\\\])" $sep "\\\\\\1" sep set match "^(-?$num_re+)(" set group [lindex $grouping 0] while { $group > 0} { set re "$match[string repeat $num_re $group])" if { ![regsub -- $re $num "\\1$sep\\2" num] } { break } if {[llength $grouping] > 1} { set grouping [lrange $grouping 1 end] } set group [lindex $grouping 0] } return $numXQL Not present: PostgreSQL, Oracle Generic XQL file: packages/acs-lang/tcl/localization-procs.xql