拆分字符串,格式是:中文+数字+中文
例子:人民币100万,英镑56万,日元289563万,新加坡币340041万。。。。。
最后一个字可以确定为万,其他的都不确定
怎么样把他们拆分成 :币种 钱数 万三块?
帮帮忙阿,谢谢了
------解决方案--------------------------------------------------------
try
string yourStr = richTextBox1.Text;
MatchCollection mc = Regex.Matches(yourStr, @ "([\u4e00-\u9fa5]+?)(\d+?)(万) ", RegexOptions.IgnoreCase);
foreach (Match m in mc)
{
richTextBox2.Text += m.Groups[1].Value + "\n "; //币种
richTextBox2.Text += m.Groups[2].Value + "\n "; //钱数
richTextBox2.Text += m.Groups[3].Value + "\n "; //万
}
------解决方案--------------------------------------------------------
string str = "人民币100万,英镑56万,日元289563万,新加坡币340041万 "; System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@ "(^|,)([\u4e00-\u9fa5]*?)(\d+)万 "); System.Text.RegularExpressions.MatchCollection ms = reg.Matches(str); for (int i = 0; i < ms.Count; i++) { Response.Write(ms[i].Result( "$2 ") + " <BR> "); Response.Write(ms[i].Result( "$3 ") + " <BR> "); }