6

Zbudowałem to wyrażenie przy http://regextester.com, aby parsować YSOD, ale VS narzeka na błąd składni. Jestem pewna, że ​​brakuje mi gdzieś ucieczki, ale jestem pusta.YSOD Żółty ekran śmierci JavaScript RegExp - Błąd składni

Tutaj jest w oryginalnej formie. każda pomoc jest doceniana.

var rxYSOD = /<!--\s*\[(.*?)]:(\s*.*\s(.*\n)*?)\s*(at(.*\n)*)-->/gs; 

UPDATE: Kobi wskazał oczywiste i got me znowu rusza. Dla tych, którzy są zainteresowani, jest to poprawny skrypt JavaScript do testowania i analizowania XMLHttpRequest.responseText dla Yellow Screen Of Death (YSOD) ASP.net.

var rxYSOD = /<!--\s*\[(.*?)]:(\s*.*\s(.*[\n\r]*)*?)\s*(at(.*[\n\r]*)*)-->/; 
if (rxYSOD.test(text)) { 
    // looks like one.. 
    var ysod = rxYSOD.exec(text); 
    errObj = { Message: ysod[2], StackTrace: ysod[4], ExceptionType: ysod[1] }; 
} 

@Kobi - Wynika to a powodem chcę analizować html chociaż dostaję 500:

{ 
"message": " Unknown web method ValidateUser.\r\nParameter name: methodName\r\n", 
"stackTrace": "at System.Web.Script.Services.WebServiceData.GetMethodData(String methodName)\r\n at System.Web.Script.Services.RestHandler.CreateHandler(WebServiceData webServiceData, String methodName)\r\n at System.Web.Script.Services.RestHandler.CreateHandler(HttpContext context)\r\n at System.Web.Script.Services.RestHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)\r\n at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)\r\n at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)\r\n at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\r\n at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)\r\n", 
"exceptionType": "ArgumentException", 
"errorObject": { 
    "Message": " Unknown web method ValidateUser.\r\nParameter name: methodName\r\n", 
    "StackTrace": "at System.Web.Script.Services.WebServiceData.GetMethodData(String methodName)\r\n at System.Web.Script.Services.RestHandler.CreateHandler(WebServiceData webServiceData, String methodName)\r\n at System.Web.Script.Services.RestHandler.CreateHandler(HttpContext context)\r\n at System.Web.Script.Services.RestHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)\r\n at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)\r\n at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)\r\n at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\r\n at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)\r\n", 
    "ExceptionType": "ArgumentException" 
}, 
"statusCode": 500, 
"servicePath": "/Authentication_JSON_AppService.axd", 
"useGet": false, 
"params": { 
    "username": "testingUser", 
    "password": "testingUser", 
    "customCredential": null 
}, 
"methodName": "ValidateUser", 
"__typeName": "Salient.ScriptModel.WebServiceError" 
} 
+0

Czy nie otrzymasz również kodu statusu "500 Wewnętrzny błąd serwera" dla tych ekranów? Mimo wszystko, powodzenia! – Kobi

+0

@Kobi, tak, z pewnością. właśnie dlatego analizuję stronę, ponieważ ma faktyczny wyjątek. Nic, co gorsze, nie jest gorsze, to wiadomość typu catch all exception, gdy informacja jest rzeczywiście dostępna. –

Odpowiedz

4

Firefox mówi:

Error: invalid regular expression flag s 
Source Code: 
var rxYSOD = /<!--\s*\[(.*?)]:(\s*.*\s(.*\n)*?)\s*(at(.*\n)*)-->/gs; 

Po usunięciu s wydaje się, że jest OK (oczywiście, nie jest testowany, tylko poprawnie przetwarzany).

+0

Dla zapisu: Ctrl + Shift + J daje konsolę błędów. – Kobi

+0

dzięki. to jedna z tych późnych nocy, kiedy moje zrozumienie tego, co oczywiste, wyciekło mi z uszu około północy. –

+0

r.e. CTRL + SHFT + J - tak, używam go całkiem sporo. Pracuję nad wieloma kodami intellisense javascript ... –

2

Flaga s jest niepoprawna w JavaScript. Aby zastąpić, użyj metody replace.

+0

dzięki, znak. masz rację, ale nie próbujesz zastąpić, po prostu dopasuj. Kobi też to przybił. –