Mega Code Archive

 
Categories / C# by API / System Globalization
 

NumberFormatInfo CurrencyGroupSeparator

using System; using System.Collections.Generic; using System.Globalization; using System.Text; using System.Text.RegularExpressions; using System.Reflection; public class MainClass{    public static void Main(){         string[] money = new string[] { "$0.99", "$0,99", "$1000000.00", "$10.25", "$90,000.00", "$90.000,00", "$1,000,000.00", "$1,000000.00" };         NumberFormatInfo info = CultureInfo.CurrentCulture.NumberFormat;         Regex moneyint = new Regex(String.Format(@"\{0}(\d{{1,3}}\{0})*\d+\{1}\d{{2}}",             info.CurrencyGroupSeparator, info.CurrencyDecimalSeparator));         foreach (string m in money)         {             Console.WriteLine("{0}: {1}", m, moneyint.IsMatch(m));         }    } }