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