Quantcast
Channel: Regular expression - only digits, dots,commas and first character should be $ - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by Sergei B. for Regular expression - only digits, dots,commas and first character should be $

$
0
0

Why not to use common approach for formatting and use appropriate IFormatProvider? Have no idea why do you need regex here...

    public static string GetFormattedCurrency(decimal value)    {        var formatInfo = new NumberFormatInfo                            {                                CurrencyDecimalSeparator = ".",                                CurrencyGroupSeparator = ",",                                CurrencyGroupSizes = new[] { 3 },                                CurrencySymbol = "$"                            };        return value.ToString("C", formatInfo);    }

Viewing all articles
Browse latest Browse all 7

Trending Articles