String ca="湖南省,长沙市";
我想要用正则表达式,查找ca中是否包含省,或都是市
应该要怎么写呢》
  Regex myRegex = new Regex("");//指定其正则验证式 
            string a = myRegex.Match(ca);//从指定内容中匹配字符串不知道Regex myRegex = new Regex("");
这个里面要怎么写了。。
麻烦各位指点

解决方案 »

  1.   

    Regex myRegex = new Regex(".+?省");
    或者
    if(ca.Contains("省"))
    {
    }
    或者
    if(ca.IndexOf("省")>0)
    {
    }
      

  2.   


    Regex myRegex = new Regex(".+?省");
    这个里面可以同时写省,或者市吗???
    而不是单独写一个省的,
      

  3.   

     String ca = "湖南省,长沙市";
                if (ca.IndexOf("省") > 0)
                {
                    //包含省
                }
                else
                {
                    //不包含省
                }
      

  4.   


    Regex.IsMatch("湖南省", @"(.*)[省市]\1")