Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

fix: LEAP-509: Optimize regular expression for improved performance #1673

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading