I have the regex:
var reValid = /^\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|[^,'\s\\]*(?:\s+[^,'\s\\]+)*)\s*(?:,\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|[^,'\s\\]*(?:\s+[^,'\s\\]+)*)\s*)*$/;
Which validates a CSV file, but I want to be able to modify the delimiter (') with any delimiter.
Is it possible to run a regex replace on a regex?
Example - use a backtick (`) as the delimiter:
var reValid = /^\s*(?:`[^`\\]*(?:\\[\S\s][^`\\]*)*`|[^,`\s\\]*(?:\s+[^,`\s\\]+)*)\s*(?:,\s*(?:`[^`\\]*(?:\\[\S\s][^`\\]*)*`|[^,`\s\\]*(?:\s+[^,`\s\\]+)*)\s*)*$/;