Communauté Eggdrop
Afficher les séparateurs de milliers dans un nombre - Version imprimable

+- Communauté Eggdrop (https://forum.eggdrop.fr)
+-- Forum : Eggdrop et TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=8)
+--- Forum : Bouts de Scripts (https://forum.eggdrop.fr/forumdisplay.php?fid=17)
+--- Sujet : Afficher les séparateurs de milliers dans un nombre (/showthread.php?tid=1577)



Afficher les séparateurs de milliers dans un nombre - MenzAgitat - 29/01/2015

tcl
proc add_thousand_separators {value} {
	return [::tcl::string::trimleft [::tcl::string::reverse [regsub -all {...} [::tcl::string::reverse $value] {& }]] " "]
}



Exemple a écrit :add_thousand_separators 16165152
Tcl: 16 165 152

ou
tcl
proc add_thousand_separators {value} {
return [::tcl::string::trimleft [::tcl::string::reverse [regsub -all {...} [::tcl::string::reverse $value] {&.}]] "."]
}



Exemple a écrit :add_thousand_separators 16165152
Tcl: 16.165.152

Source : http://www.boulets.oqp.me/tcl/routines/tcl-toolbox-0001.html