2016-12-22 2 views
1

"Exception_type"필드에 예외를로드하여 응용 프로그램에 표시하려고합니다. 나는 정규 표현식을 가지고 있지만 나에게 멀티 패러 매치 그룹을 주었다. 내가 필요한 것은 "Exception_type"필드에 대한 완전한 메시지이다. 도움이된다면 알려주기 바란다.정규식을 사용하여 전체 메시지를 추출 할 수 없습니다

는 정규식 :

(?<Exception_type>[a-zA-Z]+.*[^,]*[^ ,][^,]*$) 

메시지 :

2016-12-22 14:06:00.4563 System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:30030 
    at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) 
    at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) 
    --- End of inner exception stack trace --- 
    at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) 
    at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar) 
    --- End of inner exception stack trace --- 
    at Vinod.MyPos.MyProject.MySubProject.Vendor.Communicator.VendorSaleRequestHandler.<Send>d__13.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Vinod.MyPos.MyProject.MySubProject.Vendor.Communicator.VendorSaleRequestHandler.<Handle>d__12.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Vinod.MyPos.MyProject.MySubProject.Vendor.Communicator.VendorServiceCommunicator.<Send>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Vinod.MyPos.MyProject.MySubProject.Logging.LoggingMySubProjectChildMessageProcessor.<ProcessMessage>d__4.MoveNext() MySubProject ProcessMessage Exception : client token : [c7b9396d-b790-43f5-9561-f01c6dcdddce] 
+1

달성하고자하는 목표는 무엇입니까? 예상되는 결과는 무엇입니까? –

+0

필드에서 시작부터 끝까지 (날짜 스탬프없이) 전체 메시지가 필요합니다. Exception_type – Vinod

+0

메시지와 함께 예외 이름을 원하면 다음 정규 표현식을 사용하십시오 :'(\ w + \.) * \ w + Exception : ([a-zA-Z] + \ s ([a-zA-Z] + \)) *' – rafid059

답변

0

당신은 regex demo

^\S+\s+\S+\s+를 참조

(?s)^\S+\s+\S+\s+(?<Exception_type>.*$) 

를 사용할 수 2 첫 번째 일치 텍스트의 공백이 아닌 덩어리 1+ 공백으로 구분하고 나머지는 GUID를 제거하려면 그룹 1에 캡처

, 당신은 두 번째 단계 사용해야합니다 :

\b[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}\b 

regex demo 참조 , 빈 문자열로 대체하십시오.

여기에서 \b은 워드 경계이며 [a-fA-F0-9]은 16 진수와 일치합니다.

관련 문제