Tiny Regex improvements

Summary: Recreation of D22118786, which was so old rebasing died on some lacking meta data. Lands https://github.com/facebook/flipper/pull/1256

Reviewed By: passy

Differential Revision: D24331424

fbshipit-source-id: 65fc5d8bf0242d4266e269716a319d71ce2e2826
This commit is contained in:
Michel Weststrate
2020-10-15 09:20:07 -07:00
committed by Facebook GitHub Bot
parent 6b7b1fab5c
commit 99757622a5
5 changed files with 10 additions and 16 deletions

View File

@@ -321,7 +321,7 @@ export function parseCrashLog(
const regForName = /.*\n/;
const nameRegArr = regForName.exec(content);
let name = nameRegArr ? nameRegArr[0] : fallbackReason;
const regForCallStack = /\tat[\w\s\n.$&+,:;=?@#|'<>.^*()%!-]*$/;
const regForCallStack = /\tat[\w\s\n\.$&+,:;=?@#|'<>.^*()%!-]*$/;
const callStackArray = regForCallStack.exec(content);
const callStack = callStackArray ? callStackArray[0] : '';
let remainingString =
@@ -360,18 +360,12 @@ function truncate(baseString: string, numOfChars: number): string {
}
export function parsePath(content: string): Maybe<string> {
const regex = /Path: *[\w\-\/\.\t\ \_\%]*\n/;
const regex = /(?<=.*Path: *)[^\n]*/;
const arr = regex.exec(content);
if (!arr || arr.length <= 0) {
return null;
}
const pathString = arr[0];
const pathRegex = /[\w\-\/\.\t\ \_\%]*\n/;
const tmp = pathRegex.exec(pathString);
if (!tmp || tmp.length == 0) {
return null;
}
const path = tmp[0];
const path = arr[0];
return path.trim();
}