是否有正则表达式(或任何其他方式)来检查字符串中的数字是否在运行序列中?
例如,
"123456" will return true
"456789" will return true
"345678" will return true
"123467" will return false
"901234" will return false
最佳答案
如果您的所有序列都是由单个数字组成的,那么您可以通过观察所有正确的序列必须是最长此类序列的子串来解决此问题,即 "0123456789"
。所以检查可以这样进行:
bool res = "0123456789".Contains(str);
关于c# - 如何检查数字字符串是否在运行序列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23880606/