请告诉我这个问题的答案,请...如何查找单词和分裂的字符串的整和人物
string ss="pradeep rao having 2years exp";
在上面的字符串我想找到的年字(或)年如果字匹配,我Wnt信号分裂样
string s="2";
string s1="years(or)year"
感谢 普拉迪普
请告诉我这个问题的答案,请...如何查找单词和分裂的字符串的整和人物
string ss="pradeep rao having 2years exp";
在上面的字符串我想找到的年字(或)年如果字匹配,我Wnt信号分裂样
string s="2";
string s1="years(or)year"
感谢 普拉迪普
最简单的方法是用正则表达式,像这样:
Regex = new Regex("(\d+)(years?)");
Match match = regex.Match(ss);
if(match.Success)
{
string s = match.Groups[1];
string s1 = match.Groups[2];
}
没有解决办法,但在正确的方向提示字:
string ss = "pradeep rao having 2years exp";
string[] SPLIT = ss.split(' ');
for (int i = 0; i < SPLIT.Length; i++)
{
if (SPLIT[i].Contains("years") || SPLIT[i].Contains("year"))
{
//SPLIT[i] is the required word split it or use Substring property to get the desired result
break;
}
}
如何分割单词,如果假设我在字符串中使用10年 – 2013-03-18 10:15:52
海戴夫·塞克斯顿这里这个错误是显示 – 2013-03-18 10:17:33
无法识别的转义序列系统。 Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(“(\ d +)(years?)”); – 2013-03-18 10:18:32
雅在工作我用另一个\符号像(“(\\ d +(年?)”) – 2013-03-18 10:28:46