正则表达式匹配HTML内容

来源:互联网 发布:英国留学哪种gpa算法 编辑:程序博客网 时间:2024/05/17 01:35

匹配的正则表达式

1.<tag>[\s\S]*?</tag>

把表达式中的tag替换成对就的html元素即可


以下是HTML内容


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Log4J Log Messages</title><style type="text/css"><!--body, table {font-family: arial,sans-serif; font-size: x-small;}th {background: #336699; color: #FFFFFF; text-align: left;}--></style></head><body bgcolor="#FFFFFF" topmargin="6" leftmargin="6"><hr size="1" noshade>Log session start time Sun Nov 25 13:03:31 CST 2012<br><br><table cellspacing="0" cellpadding="4" border="1" bordercolor="#224466" width="100%"><tr><th>Time</th><th>Thread</th><th>Level</th><th>Category</th><th>Message</th></tr><tr><td>289747</td><td title="pool-1-thread-5 thread">pool-1-thread-5</td><td title="Level"><font color="#993300"><strong>ERROR</strong></font></td><td title="com.raycloud.dao.manager.ShopCheckManagerImpl category">com.raycloud.dao.manager.ShopCheckManagerImpl</td><td title="Message">tb7468291检测当天上架宝贝数量时出现错误null</td></tr><tr><td bgcolor="#993300" style="color:White; font-size : xx-small;" colspan="6">java.lang.NullPointerException<br>    at com.raycloud.dao.manager.ShopCheckManagerImpl.checkListNum(ShopCheckManagerImpl.java:593)<br>    at sun.reflect.GeneratedMethodAccessor154.invoke(Unknown Sourc<br>    at java.lang.Thread.run(Thread.java:619)</td></tr><tr><td>703083</td><td title="pool-1-thread-2 thread">pool-1-thread-2</td><td title="Level"><font color="#993300"><strong>ERROR</strong></font></td>oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<td title="com.raycloud.thread.ItemCheckFactory category">com.raycloud.thread.ItemCheckFactory</td><td title="Message">taskId ==  170284 taskType == {"check_search":"1","check_goods":"1","check_list":"1","check_showcase":"1"} taobaoNick ==  名媛服饰商城 task 失败 =  session 失效,需要重新登录。用时183</td></tr><tr><td bgcolor="#993300" style="color:White; font-size : xx-small;" colspan="6">java.lang.Exception: session 失效,需要重新登录。<br>    at com.raycloud.dao.impl.ItemDaoImpl.queryInstockItemFromTaobao(ItemDaoImpl.java:410)<br>    at sun.reflect.GeneratedMethodAccessor136.invoke(Unknown Source)<br>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>    at java.lang.reflect.Method.invoke(Method.java:597)<br>    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)<br>    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)<br>    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)<br>    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)<br>    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)<br>    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)<br>    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)<br>    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)<br>    at $Proxy19.queryInstockItemFromTaobao(Unknown Source)<br>    at com.raycloud.thread.ItemCheckFactory.check(ItemCheckFactory.java:98)<br>    at com.raycloud.thread.ItemCheckTaskThread.run(ItemCheckTaskThread.java:65)<br>    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)<br>    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)<br>    at java.lang.Thread.run(Thread.java:619)</td></tr><tr><td>769698</td><td title="pool-1-thread-3 thread">pool-1-thread-3</td><td title="Level"><font color="#993300"><strong>ERROR</strong></font></td><td title="com.raycloud.thread.ItemCheckFactory category">com.raycloud.thread.ItemCheckFactory</td><td title="Message">taskId ==  170304 taskType == {"check_search":"1","check_goods":"1","check_list":"1","check_showcase":"1"} taobaoNick ==  我家的菲 task 失败 =  session 失效,需要重新登录。用时97</td></tr>;;;;;;;kljkllllllllllllllllll<tr><td bgcolor="#993300" style="color:White; font-size : xx-small;" colspan="6">java.lang.Exception: session 失效,需要重新登录。<br>    at com.raycloud.dao.impl.ItemDaoImpl.queryInstockItemFromTaobao(ItemDaoImpl.java:410)<br>    at sun.reflect.GeneratedMethodAccessor136.invoke(Unknown Source)<br>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>    at java.lang.reflect.Method.invoke(Method.java:597)<br>    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)<br>    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)<br>    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)<br>    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)<br>    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)<br>    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)<br>    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)<br>    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)<br>    at $Proxy19.queryInstockItemFromTaobao(Unknown Source)<br>    at com.raycloud.thread.ItemCheckFactory.check(ItemCheckFactory.java:98)<br>    at com.raycloud.thread.ItemCheckTaskThread.run(ItemCheckTaskThread.java:65)<br>    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)<br>    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)<br>    at java.lang.Thread.run(Thread.java:619)</td></tr>




以下引用正则表达式的符号说明

正则表达式到底是什么东西?

在编写处理字符串的程序或网页时,经常会有查找符合某些复杂规则的字符串的需要。正则表达式就是用于描述这些规则的工具。换句话说,正则表达式就是记录文本规则的代码。
常用元字符
代码说明.匹配除换行符以外的任意字符\w匹配字母或数字或下划线或汉字\s匹配任意的空白符\d匹配数字\b匹配单词的开始或结束^匹配字符串的开始$匹配字符串的结束
常用限定符
代码/语法说明*重复零次或更多次+重复一次或更多次?重复零次或一次{n}重复n次{n,}重复n次或更多次{n,m}重复n到m次
常用反义词
代码/语法说明\W匹配任意不是字母,数字,下划线,汉字的字符\S匹配任意不是空白符的字符\D匹配任意非数字的字符\B匹配不是单词开头或结束的位置[^x]匹配除了x以外的任意字符[^aeiou]匹配除了aeiou这几个字母以外的任意字符
原创粉丝点击