Many stores now like to buy custom templates, and there are various design drafts. Some design drafts also want to make the decimal point of the price different from other numbers. This can't be done with pure CSS without adding tags. No way to format the prices as HTML with tagsCode.
.
1 String Getpricehtml ( String Price)
2 {
3 If ( String . Isnullorempty (price ))
4 {
5 Return String . Empty;
6 }
7
8 VaR Numberformat = thread. currentthread. currentuiculture. numberformat;
9 VaR Decimalseparator = numberformat. currencydecimalseparator;
10 VaR Groupseparator = numberformat. currencygroupseparator;
11
12 If (Price. Contains (decimalseparator ))
13 {
14 VaR Numberregex = New RegEx ( String . Format ( @" [\ {0} \ D] + \ {1} " , Groupseparator, decimalseparator ));
15 Price = numberregex. Replace (price, Delegate (Match)
16 {
17 Return String . Format ( @" <SPAN class = "" Number ""> {0} </span> {1} " , Match. value. substring ( 0 , Match. value. Length- 1 ), Decimalseparator );
18 });
19
20 VaR Decimalregex =New RegEx ( String . Format ( @" \ {0} \ D + $ " , Decimalseparator ));
21 Price = decimalregex. Replace (price, Delegate (Match)
22 {
23 Return String . Format ( @" <SPAN class = "" Decimal-separator ""> {0} </span> <SPAN class = "" decimal "" >{1} </span> " , Decimalseparator, match. value. substring ( 1 ));
24 });
25 } Else
26 {
27 VaR Numberregex = New RegEx ( String . Format (@" [\ {0} \ D] + " , Groupseparator ));
28 Price = numberregex. Replace (price, Delegate (Match)
29 {
30 Return String . Format ( @" <SPAN class = "" Number ""> {0} </span> " , Match. value );
31 });
32 }
33
34 VaR Symbol = numberformat. currencysymbol;
35 Price = Price. Replace (symbol, String . Format ( @" <SPAN class = "" symbol ""> {0} </span> " , Symbol ));
36
37 Return Price;
38 }
Test code:
1 VoidMain ()
2{
3Thread. currentthread. currentuiculture =NewCultureinfo ("NL-nl");
4Console. writeline (getpricehtml ("€0. 2.300, 20"));
5}
Result:
<SPAN class = "symbol"> € </span> <SPAN class = "Number"> 2.300 </span> <SPAN class = "Decimal-separator">, </span> <SPAN class = "decimal"> 20 </span>