所以我有一个特定的日志文件:
Jul 07, 2014 12:56:06 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jul 07, 2014 12:56:07 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/admin] created a ThreadLocal with key of type [com.sun.xml.bind.v2.ClassFactory$1] (value [com.sun.xml.bind.v2.ClassFactory$1@75443fb0]) and a value of type [java.util.WeakHashMap] (value [{class com.hp.sw.bto.security.internal.jaxb.MultiValueMapAdapter=java.lang.ref.WeakReference@53b177f5, class com.hp.sw.bto.security.internal.PrincipleImpl=java.lang.ref.WeakReference@283aa0c0, class java.util.ArrayList=java.lang.ref.WeakReference@210fb1e2, class com.hp.sw.bto.security.internal.jaxb.MultivalueMapEntry=java.lang.ref.WeakReference@d677d63, class com.hp.sw.bto.security.context.builders.SecurityContextSectionBuilder$SecurityContextSectionImpl=java.lang.ref.WeakReference@558f575, class com.hp.sw.bto.security.authz.internal.AuthzPermissionImpl=java.lang.ref.WeakReference@135ad711, class com.hp.sw.bto.security.context.builders.GroupBuilder$GroupImpl=java.lang.ref.WeakReference@30dda704, class com.hp.sw.bto.security.context.builders.RoleBuilder$RoleImpl=java.lang.ref.WeakReference@280010ac, class com.hp.sw.bto.security.internal.jaxb.MultivalueMap=java.lang.ref.WeakReference@1c46a0b8, class com.hp.sw.bto.security.internal.SecurityContextImpl=java.lang.ref.WeakReference@60e19e88}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Jul 07, 2014 12:56:08 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/admin] created a ThreadLocal with key of type [com.sun.xml.bind.v2.runtime.Coordinator$1] (value [com.sun.xml.bind.v2.runtime.Coordinator$1@7c6f2468]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@64bf67aa]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Jul 07, 2014 12:56:09 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/admin] created a ThreadLocal with key of type [com.sun.xml.bind.v2.ClassFactory$1] (value [com.sun.xml.bind.v2.ClassFactory$1@75443fb0]) and a value of type [java.util.WeakHashMap] (value [{class com.hp.sw.bto.security.internal.PrincipleImpl=java.lang.ref.WeakReference@522efd92, class java.util.ArrayList=java.lang.ref.WeakReference@b09a665, class com.hp.sw.bto.security.internal.jaxb.MultivalueMapEntry=java.lang.ref.WeakReference@268b368c, class com.hp.sw.bto.security.context.builders.SecurityContextSectionBuilder$SecurityContextSectionImpl=java.lang.ref.WeakReference@7daa3518, class com.hp.sw.bto.security.authz.internal.AuthzPermissionImpl=java.lang.ref.WeakReference@3183fb1c, class com.hp.sw.bto.security.context.builders.GroupBuilder$GroupImpl=java.lang.ref.WeakReference@4fdb04a9, class com.hp.sw.bto.security.context.builders.RoleBuilder$RoleImpl=java.lang.ref.WeakReference@340f1c34, class com.hp.sw.bto.security.internal.jaxb.MultivalueMap=java.lang.ref.WeakReference@4c04b49f, class com.hp.sw.bto.security.internal.SecurityContextImpl=java.lang.ref.WeakReference@48ee59b6}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Jul 07, 2014 12:56:10 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/admin] created a ThreadLocal with key of type [com.sun.xml.bind.v2.runtime.Coordinator$1] (value [com.sun.xml.bind.v2.runtime.Coordinator$1@7c6f2468]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@1843e122]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
我正在尝试解析它。但是,当我在测试中尝试我的正则表达式时,它工作正常并匹配我想要的。 http://regex101.com/r/sL4eR0/13 但是当我在代码上尝试时,它会跳过第一个匹配并在之后输出所有匹配。我不太清楚为什么或如何解决它。 代码:http://jsfiddle.net/j7rXu/6/
答案 0 :(得分:1)
看起来regex.test(localcat)
的调用正在吃正则表达式的第一场比赛。如果在循环调用regex.exec(localcat)
之前删除此行,则应在循环中包含第一个匹配项。
var match, regex = /^([a-zA-Z]*): (.*)(?:\s)([^co]+) ([^\s]+) (\w*)$/gm, localcat = ((reader.result).split("\n").reverse().join("\n"));
// This line eats the first match of the regex
// alert(regex.test(localcat));
while ((match = regex.exec(localcat)) !== null){
alert(match[0]);
if(match[1]==="SEVERE"){
document.getElementById("hey").innerHTML+= ("Time: " + match[3] + "<br/>");
}
}
RegExp.prototype.test()的description声明:
与exec(或与exec一起)一样,多次调用 在同一个全局正则表达式实例上将超越 上一场比赛。
答案 1 :(得分:1)
您的模式不再起作用的原因是您在应用模式之前拆分/反向/连接所有行。结果,现在每个记录之前的所有日期都在单独的行上,但您的模式设计为与原始订单一起使用。了解分割/反向/加入后localcat
的样子:
Jul 07, 2014 12:56:06 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-nio-8080"]
Jul 07, 2014 12:56:06 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8443"]
Jul 07, 2014 12:56:06 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-apr-8009"]
Jul 07, 2014 12:56:06 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jul 07, 2014 12:56:07 AM org.apache.catalina.loader.WebappClassLoader check...
SEVERE: The web application [/admin] created a ThreadLocal with key of type...
Jul 07, 2014 12:56:08 AM org.apache.catalina.loader.WebappClassLoader check...
SEVERE: The web application [/admin] created a ThreadLocal with key of type...
Jul 07, 2014 12:56:09 AM org.apache.catalina.loader.WebappClassLoader check...
SEVERE: The web application [/admin] created a ThreadLocal with key of type...
Jul 07, 2014 12:56:10 AM org.apache.catalina.loader.WebappClassLoader check...
SEVERE: The web application [/admin] created a ThreadLocal with key of type...
这就是为什么你获得除了上一个记录的日期/时间以外的所有记录。
好方法可能是提取所需的所有数据,然后才能反转结果数组。另一种可能性是为这个新订单重写您的模式(see demo)。您也可以选择逐行工作。