2015-01-29 1 views
0

나는 다음과 같은 정규식 표현이 : 자바 스택 트레이스를 일치하도록 시도일치 모든

(?<time>[^ ]* [^ ]*) (?<class>[^ ]+) *(?<level>[^ ]+)[ -]+(?<message>.*) 

, 샘플이있는 것입니다 :

2015-01-28 18:48:33,484 grails.plugin.jms.JmsGrailsPlugin     INFO - registering listener for 'sendPostLinkByEmailToUnbindedContacts' of service 'postCreatedActivityListener' to TOPIC 'post.created' 
2015-01-28 18:48:35,569 sf.ehcache.config.ConfigurationFactory    WARN - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/var/lib/tomcat7/webapps/ws/WEB-INF/lib/ehcache-core-2.4.8.jar!/ehcache-failsafe.xml 
2015-01-28 18:48:37,809 proxy.pojo.javassist.JavassistLazyInitializer  ERROR - HHH000142: Javassist Enhancement failed: hibe.core.communication.feed.Post 
java.lang.RuntimeException: duplicate method: attach in hibe.core.communication.feed.Post_$$_javassist_64 
     at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:509) 
     at ... 

내 정규식과 더를위한 Rubular Link 참조 완전한 입력 샘플.

전체 메시지와 일치하지 않는 message 그룹을 제외하고 내 정규 표현식이 정상적으로 작동합니다. message 그룹에 다음 스택 톤까지 포함되도록해야합니다. 다음 형식이이 형식의 날짜인지 여부를 알 수있는 패턴 : 2015-01-28 18 : 48 : 33,484

가능합니까?

답변

1

사용 :

  • DOTALL 플래그, 도트가 개행 문자와 일치하도록 너무
  • 룩어 그래서, 최대 소비하지만 다음 날짜 스탬프
  • 꺼려 정량 *? 포함하지 않도록 일치는 마지막 날짜까지의 모든 입력을 소비하지 않습니다.

마찬가지로 :

(?<time>[^ ]* [^ ]*) (?<class>[^ ]+) *(?<level>[^ ]+)[ -]+(?<message>.*?(?=\d{4}-\d\d-\d\d \d\d:\d\d:\d\d,\d{3})) 

demo

+0

고마워하세요! 멀티 라인 모드 없이도 사용할 수 있습니까? –

관련 문제