static void Main(string[] args)
{
Regex reg = new Regex(@"url\((['""]?)(.+[^'""])\1\)"); //注意里面的引号 要用双引号表示,而不是用反斜杠
Console.WriteLine(reg.Match(@"{background-image:url(//ssl.gstatic.com/ui/v1/menu/checkmark.png);backgro")); //输出 url(//ssl.gstatic.com/ui/v1/menu/checkmark.png)
Console.ReadKey();
}
static void Main(string[] args)
{
Regex reg = new Regex(@"\b(?<group>\w+ +)\k<group>");
string str = "what the hell are you you talking about?";
Console.WriteLine(reg.Match(str));
Console.ReadKey();
}
static void Main(string[] args)
{
Regex reg1 = new Regex(@"\d+");
string str = reg1.Replace("123","insert into table where id = $&");
Console.WriteLine(str); //输出 insert into table where id = 123
Regex reg2 = new Regex(@"1\+1=(\d)");
string str2 = reg2.Replace("1+1=3","不是$1");
Console.WriteLine(str2); //输出 不是3
Regex reg3 = new Regex(@"1\+1=(?<result>\d)");
string str3 = reg3.Replace("1+1=3", "不是${result}");
Console.WriteLine(str3); //输出 不是3
Regex reg4 = new Regex(@"\d+");
string str4 = reg4.Replace("123ABC", "后面是$'"); //匹配文本之后的文本
Console.WriteLine(str4); //输出 后面是ABCABC 为什么会输出 后面是ABCABC呢?因为$'指的是ABC,然后替换掉原字符串中的123。不懂看多几次这句话
Regex reg5 = new Regex(@"\d+");
string str5 = reg5.Replace("ABC123", "前面是$`"); //ABC前面是ABC 符号是 1左边那个
Console.WriteLine(str5);
Regex reg6 = new Regex(@"\d+");
string str6 = reg6.Replace("ABC123","右边原始输入字符串$_");
Console.WriteLine(str6); //输出 右边是原始字符串ABC123
Console.ReadKey();
}
static void Main(string[] args)
{
string str = File.ReadAllText(@"D:\daoru.txt", Encoding.Default);
Regex reg = new Regex(@".+");
string str1 = reg.Replace(str, "insert into Keyword values(196,'admin1','admin1','$&')");
File.WriteAllText(@"D:\123.txt", str1);
Console.ReadKey();
}
static void Main(string[] args)
{
string str = File.ReadAllText(@"D:\daoru.txt", Encoding.Default);
Regex reg = new Regex(@".+");
string str1 = reg.Replace(str, "insert into JM_SinaBlog_KeyWord values(105,'jmeii','jmeii','$&')").Replace((char)13, (char)0);//here
File.WriteAllText(@"D:\123.txt", str1);
Console.ReadKey();
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有