薄·客 - 正则
type: channel
link: https://blog.mintcore.cn/index.php/tag/%E6%AD%A3%E5%88%99/
items: C# 正则表达式 判断string 是否是数字
items: C# 用正则表达式实现金额转中文大写

C# 正则表达式 判断string 是否是数字
type: item
date: 2022-05-20T09:55:00+08:00
description: [collapse status="true" title="点击收缩查看代码"]public static bool IsNumeric(string value) { return Regex.IsMatch(value, @"^[+-]?\d*[.]?\d*$"); } public static bool IsInt(string value) { return Regex.IsMatch(value, @"^[+-]?\d*$"); } public static bool IsUnsign(string value) { return Regex.IsMatch(value, @"^\d*[.]?\d*$"); } public static bool isTel(string strInput) { return Regex.IsMatch(strInput, @"\d{3}-\d{8}|\d{4}-\d{7}"); }[/collapse]

C# 用正则表达式实现金额转中文大写
type: item
date: 2022-05-20T09:51:00+08:00
description: [collapse status="true" title="点击收缩查看代码"] public static string MoneyToCap(string money) { if (string.IsNullOrEmpty(money)) { return ""; } string s = double.Parse(money).ToString("#L#E#D#C#K#E#D#C#J#E#D#C#I#E#D#C#H#E#D#C#G#E#D#C#F#E#D#C#.0B0A"); string d = Regex.Replace(s, @"((?<=-|^)[^1-9]*)|((?'z'0)[0A-E]*((?=[1-9])|(?'-z'(?=[F-L.]|$))))|((?'b'[F-L])(?'z'0)[0A-L]*((?=[1-9])|(?'-z'(?=[.]|$))))", "${b}${z}"); return Regex.Replace(d, ".", delegate(Match m) { return "负圆空零壹贰叁肆伍陆柒捌玖空空空空空空空分角拾佰仟万億兆京垓秭穰"[m.Value[0] - '-'].ToString(); }); }[/collapse]