>Date: Sun, 18 Jan 2009 04:27:44 +0100
>From: Marcus <[email protected]>
>Subject: [pmwiki-users] Formatting numbers
>
>Is there a way to format numbers?
>If I have a form variable "1.5", is there a way to add a zero *only*
>if the variable has one digit after the decimal point?
>
>1.5 becomes 1.50
>1.54 stays as 1.54
>
>Thanks,
>
>Marcus
>
You could experiment with a markup rule like this:
Markup('fmtzero','inline','/([\d]+\.\d)([^\d])/e',"'$1'.'0'.'$2'");
This might have strange side effects, like the pagename
Foo123.1Bar becoming Foo123.10Bar, so perhaps a more
restrictive rule:
Markup('fmtzero','inline','/([\d]+\.\d)(\s)/e',"'$1'.'0 '");
Hope this helps.
--
John Rankin
Affinity Limited
T 64 4 495 3737
F 64 4 473 7991
021 RANKIN
[email protected]
www.affinity.co.nz
_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users