我想匹配以下单词
树 , tree.com , tree123 , 123tree , tree-up ,
我做了以下条件..它可以正常工作,但我想将它们加入一个正则表达式
bool res1=Regex.IsMatch(term, "^[a-zA-Z-.]+$",RegexOptions.IgnoreCase)
//works well but it matches . and - if they come alone i want a solution ?!
bool res2=Regex.IsMatch(term, "^[a-zA-Z-.]+[0-9]+$",RegexOptions.IgnoreCase) //works well
bool res3=Regex.IsMatch(term,"^[0-9]+[a-zA-Z-.]+$", RegexOptions.IgnoreCase)//works well
我知道我可以使用
if(res1 || res2 || res3 ) {}
但我想在 1 个表达式中加入这些表达式