>2000<10102010>7000<123123:其中2000和7000的左右是>和<,只要确定><的位置,然后用substring函数获取;

解决方案 »

  1.   

    1。 string s = ">2000<10102010>7000<123123";
    string ex = @"(?<!\d)[0-9]{4}(?!\d)";
    MatchCollection matches = Regex.Matches( s,ex );
    foreach( Match match in matches )
    {
       MessageBox.Show( match.Value );
    }2。 string s = ">2000and<10000>and1000";
    string ex = @"(?<!\d)[a-zA-Z]+(?![><=])";
    MatchCollection matches = Regex.Matches( s,ex );
    foreach( Match match in matches )
    {
       MessageBox.Show( match.Value );
    }注:第二个正则中,会把">2000and<"中的n当作合法的字母抓出来
    因为,它也符合你的规则
    所以,使用的时候要注意一下