From 4e777d3540c0a9dc1c590563d0de924e00ec3034 Mon Sep 17 00:00:00 2001 From: Julio Sgarbi Date: Wed, 24 Jan 2024 17:46:18 -0300 Subject: [PATCH] fix: LEAP-509: Optimize regular expression for improved performance (#1673) --- src/utils/data.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/data.js b/src/utils/data.js index edf0f63b9..2ca61afa0 100644 --- a/src/utils/data.js +++ b/src/utils/data.js @@ -72,9 +72,9 @@ export const parseCSV = (text, separator = 'auto') => { const re = new RegExp( [ - '"(""|[^"]+)*"', // quoted text with possible quoted quotes inside it ("not a ""value""") + '"(?:""|[^"])*"', // quoted text with possible quoted quotes inside it ("not a ""value""") `[^"${separator}]+`, // usual value, no quotes, between separators - `(?=${separator}(${separator}|$))`, // empty value in the middle or at the end of string + `(?=${separator}(?:${separator}|$))`, // empty value in the middle or at the end of string `^(?=${separator})`, // empty value at the start of the string ].join('|'), 'g',