摘要: 写了一个判断四则运算合法性较验的式子。public static bool CheckExpressionValid(string input){ string pattern = @"^(((?<o>\()[-+]?([0-9]+[-+*/])*)+[0-9]+((?<-o>\))([-+*/][0-9]+)*)+($|[-+*/]))*(?(o)(?!))$"; //去掉空格,且添加括号便于进行匹配 return Regex.IsMatch("(" + input.Replace(" ", "&q 阅读全文
posted @ 2012-10-22 10:29 码写人生 阅读(1415) 评论(0) 推荐(0)