String3%!$!xfaString
头尾String相同,String为任意长度任意字符串求一正则表达式匹配上述字符串?谢谢各位。

解决方案 »

  1.   

    string str = @"String3%!$!xfaString";
            Regex re = new Regex(@"(?is).*3%!\$!xfa.*");
            foreach (Match ma in re.Matches(str))
            {
                Response.Write(ma.Value);
            }
    //把那两个String换成你想要的字符串
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;namespace ConsoleApplication12
    {
        class Program
        {
            static void Main(string[] args)
            {
                string str = @"qq3%!$!xfaqq";
                Regex regex = new Regex(@"(?is)^(.*)3%!\$!xfa\1$");
                Console.Write(regex.IsMatch(str));
                /*true*/
            }
        }
    }
      

  3.   

    String3%!$!xfaString如果你的 3%!$!xfa 没其他特殊含义的话就这样写:  (.*)3%!\$!xfa\1