Regex re = new Regex("^" + drowUrlType.UrlTypeValue.Trim() + "$", RegexOptions.IgnoreCase);^ , $,什么意思??
在线等...

解决方案 »

  1.   

    比如这样源字符串:abc123
    正则表达式一:\d+
    正则表达式二:^\d+$表达式一匹配成功,匹配的结果为:123
    表达式二匹配失败,因为它要求从开始位置和结束位置之间,都是数字,而源字符串显然是不符合要求的^和$本身并不匹配任何字符,它们只是与开始位置和结束位置匹配
      

  2.   

    例如:
    abc
    def
    ghijklmn
    ^就表示字符串开始,也就是a的前面,$就表示字符串结束,n的后面。如果n后面有\n,\n会被忽略
      

  3.   

    从^ 开始到$结束的和drowUrlType.UrlTypeValue.Trim()相匹配的内容。
      

  4.   

    我举个例子:
    apphost="192.168.1.150"
    drowUrlType.UrlTypeValue="192.168.1.150/blog"
    Regex re = new Regex("^" + drowUrlType.UrlTypeValue.Trim() + "$", RegexOptions.IgnoreCase);
                    if (re.IsMatch(apphost))
                    {                    textbox1.text="成功";
                    }
                }
    结果会是怎么样了??
      

  5.   

    结果会是怎么样了??
    -----------
    什么都没有,因为匹配失败如果apphost和drowUrlType.UrlTypeValue完全固定,就没必要用正则了
      

  6.   

    我举个例子:
    apphost="192.168.1.150/blog"
    drowUrlType.UrlTypeValue="192.168.1.150"
    Regex re = new Regex("^" + drowUrlType.UrlTypeValue.Trim() + "$", RegexOptions.IgnoreCase);
                    if (re.IsMatch(apphost))
                    {                    textbox1.text="成功";
                    }
                }
    结果会是怎么样了??