本文介绍了计算字符串在字符串中出现的次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是有一个看起来像这样的字符串:
7,true,NA,false:67,false,NA,false:5, NA,false:5,false,NA,false
所有我想做的是计算字符串true出现在字符串中的次数。我感觉像是答案是类似String.CountAllTheTimesThisStringAppearsInThatString(),但由于某种原因,我只是不能弄清楚。帮助?
解决方案
Regex.Matches(Regex.Escape ).Count
I simply have a string that looks something like this:
"7,true,NA,false:67,false,NA,false:5,false,NA,false:5,false,NA,false"
All I want to do is to count how many times the string "true" appears in that string. I'm feeling like the answer is something like String.CountAllTheTimesThisStringAppearsInThatString() but for some reason I just can't figure it out. Help?
解决方案
Regex.Matches(Regex.Escape(input), "true").Count
这篇关于计算字符串在字符串中出现的次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!