1111111111111
前边有内容,不定123.123.123.10后边有内容,不定
3333333333333
4444444444444
如何匹配"非:.+123.123.123.10.+"
行
匹配结果是,
1111111111111
3333333333333
4444444444444
结论:
^(?!.*123.123.123.10).*$
或C#里这么操作:
textBox2.Text=Regex.Replace(textBox1.Text,@"n.*123.123.123.10.*n","nrn");
stringresult=Regex.Replace(str,@"^.*?123.123.123.10.*$","",RegexOptions.Multiline);
Regexreg=newRegex(@"(?<=^|rn)(?!123.123.123.10).+");
总结:
匹配非“非内容”的行的表达式应该写成:^(?!.*非内容).*$
===================================
另,再来个例子:
2008-07-1415:44:40W3SVC49160.27.236.4GET/Item/How-To-Connection-My-Computer-Flow-IP-yongfa365.html-80-74.6.22.106Mozilla/5.0+(compatible;+Yahoo!+Slurp;+http://help.yahoo.com/help/us/ysearch/slurp)20000
2008-07-1415:44:51W3SVC49160.27.236.4GET/item/Clear.bat-System-Windows-98-XP-2003-yongfa365.html-80-124.73.140.102Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0)200064
2008-07-1415:44:51W3SVC49160.27.236.4GET/item/Clear.bat-System-Windows-98-XP-2003-yongfa365.html-80-124.73.140.102Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0)206064
2008-07-1415:47:11W3SVC49160.27.236.4GET/Articles.xml-80-65.214.44.28Bloglines/3.1+(http://www.bloglines.com;+1+subscriber)200064
2008-07-1415:47:47W3SVC49160.27.236.4GET/Item/SQL-Server-Store-More-Than-8000-WRITETEXT-UPDATETEXT-yongfa365.html-80-59.125.118.13Trend+Micro+Web+Protection+Add-On+1.10.114420000
找出上而面的行里的,不是以“200064”结尾的行,然后删除
^(?!.*200064).*$
而我一直是这么测试的:
^(?!.*200064)$
没有后边的.*因为我觉得后边已经没有内容了,所以没写.*而不写就不对,写了才行,哪位高人可以再指点下。