标签:style blog color for sp div on 问题 log
代码如下
string a = "长花asdsad1236李代5415老花1213"; int j = 0; int k = 0; bool id = true; for (int i = 0; i < a.Length;i++ ) { if (a[i] >= ‘0‘ && a[i] <= ‘9‘) { if (id) { k = i; id = false; } if (i < a.Length - 1) { if (a[i + 1] >= ‘0‘ && a[i + 1] <= ‘9‘) { continue; } else { Response.Write(a.Substring(j, k - j) + ":" + a.Substring(k, i + 1 - k)); id = true; j = i + 1; } } else { Response.Write(a.Substring(j, k - j) + ":" + a.Substring(k, i + 1 - k)); } } }
输出结果为
长花asdsad:1236李代:5415老花:1213
这段代码还有待优化。希望大神指正
标签:style blog color for sp div on 问题 log
原文地址:http://www.cnblogs.com/llcdbk/p/4028898.html