正则表达式匹配 非XXX的行
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");
string result = Regex.Replace(str, @"^.*?123.123.123.10.*$", "", RegexOptions.Multiline);
Regex reg =new Regex(@"(?<=^|rn)(?!123.123.123.10).+");
总结:
匹配非“非内容”的行的表达式应该写成:^(?!.*非内容).*$
===================================
另,再来个例子:
2008-07-14 15:44:40 W3SVC491 60.27.236.4 GET /Item/How-To-Connection-My-Computer-Flow-IP-yongfa365.html - 80 - 74.6.22.106 Mozilla/5.0+(compatible;+Yahoo!+Slurp;+http://help.yahoo.com/help/us/ysearch/slurp) 200 0 0
2008-07-14 15:44:51 W3SVC491 60.27.236.4 GET /item/Clear.bat-System-Windows-98-XP-2003-yongfa365.html - 80 - 124.73.140.102 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 200 0 64
2008-07-14 15:44:51 W3SVC491 60.27.236.4 GET /item/Clear.bat-System-Windows-98-XP-2003-yongfa365.html - 80 - 124.73.140.102 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 206 0 64
2008-07-14 15:47:11 W3SVC491 60.27.236.4 GET /Articles.xml - 80 - 65.214.44.28 Bloglines/3.1+(http://www.bloglines.com;+1+subscriber) 200 0 64
2008-07-14 15:47:47 W3SVC491 60.27.236.4 GET /Item/SQL-Server-Store-More-Than-8000-WRITETEXT-UPDATETEXT-yongfa365.html - 80 - 59.125.118.13 Trend+Micro+Web+Protection+Add-On+1.10.1144 200 0 0
找出上而面的行里的,不是以“200 0 64”结尾的行,然后删除
^(?!.*200 0 64).*$
而我一直是这么测试的:
^(?!.*200 0 64)$
没有后边的.* 因为我觉得后边已经没有内容了,所以没写 .* 而不写就不对,写了才行,哪位高人可以再指点下。
正则表达式不包含属性
找出所有img标签的,没有带说明属性alt的标签:正则:img(?![^]*?alt[^]*?).*?例子:imgsrc=""alt=""imgsrc=""imgsrc=""title=""imgsrc=""id=""imgsrc=""title=""alt=""扩展,如果要
ASP正则函数替换分页后的参数
FunctionDRexPage(Str)DimRegExIfIsNull(Str)OrStr=""ThenExitFunctionSetRegEx=NewRegExpRegEx.IgnoreCase=TrueRegEx.pattern="(&)?page=(d)+"DRexPage=regEx.replace(Str,"")'(Str,"$1")SetRegEx=NothingEndFunc
asp match正则函数使用Matchs实例
说明Match对象只能通过RegExp对象的Execute方法来创建,该方法实际上返回了Match对象的集合。所有的Match对象属性都是只读的。在执行正则表达式时,可能
编辑:编程语言
标签:正则,内容,对象,属性,函数