VBScript正则表达式无法获取状态代码

时间:2019-05-07 03:48:01

标签: regex vbscript

我与下面的VBScript不匹配。我的代码有问题吗?

测试

Error Type: SMTP[nl] Remote server (166.216.149.129) issued an error.[nl] hMailServer sent: RCPT TO:<8583390609@txt.att.net>[nl] Remote server replied: 550 5.1.1 <8583390609@txt.att.net> recipient does not exist here.[nl]

模式

^.*Remote server replied: ([0-9]{3}).*$

记录

3544    "2019-05-06 23:09:51.609"   "Running" 
3544    "2019-05-06 23:09:51.609"   "Error Type: SMTP[nl] Remote server (166.216.149.129) issued an error.[nl] hMailServer sent: RCPT TO:<8583390609@txt.att.net>[nl] Remote server replied: 550 5.1.1 <8583390609@txt.att.net> recipient does not exist here.[nl]" 
3544    "2019-05-06 23:09:51.609"   "No Match"

VBScript

Dim regex, matches, match, strResult

    EventLog.Write("Running")
    EventLog.Write(sErrorMessage)

    Set regex = New RegExp
    regex.IgnoreCase = True
    regex.Pattern = "^.*Remote server replied: ([0-9]{3}).*$"

    Set matches = regex.Execute(sErrorMessage)

    If matches.Count >= 1 Then
            Set match = matches(0)
            If match.SubMatches.Count >= 1 Then
                strResult = match.SubMatches(0)
            EventLog.Write(strResult)
            Else
EventLog.Write("NO SUBMATCHES")
                strResult = ""
                exit sub
            End If
    Else
EventLog.Write("No Match")
            strResult = ""
            exit sub
    End If

1 个答案:

答案 0 :(得分:-1)

//removed stacktrace
[C:\Softwares\apache-tomcat-9.0.19\webapps\testWeb] has finished in [21,474] ms
[C:\Softwares\apache-tomcat-9.0.19\webapps\testWebH] has finished in [15,119] ms
07-May-2019 10:07:40.114 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-7000"]
07-May-2019 10:07:40.166 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
07-May-2019 10:07:40.175 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [36,756] milliseconds
07-May-2019 10:08:21.865 SEVERE [http-nio-7000-exec-1] com.local.test.tag.ExceptionTagHandler.doEndTag Name [jdbc/myProxy] is not bound in this Context. Unable to find [jdbc].
 javax.naming.NameNotFoundException: Name [jdbc/myProxy] is not bound in this Context. Unable to find [jdbc].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:817)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
    at org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(ResourceLinkFactory.java:152)
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:840)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:827)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
    at com.local.test.service.ConnectionProvider.getMyDatasource(ConnectionProvider.java:536)
    at com.local.test.tag.ExceptionTagHandler.doEndTag(ExceptionTagHandler.java:549)
    at org.apache.jsp.WEB_002dINF.resources.error.errorpage_jsp._jspx_meth_m_005fexception_005f0(errorpage_jsp.java:153)
//removed stacktrace

[nl]是换行符,我想我需要告诉正则表达式。