Skip to content

Instantly share code, notes, and snippets.

View albannurkollari's full-sized avatar

Erenndriel albannurkollari

View GitHub Profile
@albannurkollari
albannurkollari / regexWithOcurrencePattern.ts
Last active April 10, 2024 21:39
Regex with ocurrence pattern helper
export const regexWithOccurrencePattern = (regex: RegExp | string) => {
const source = regex instanceof RegExp ? regex.source : regex;
return new RegExp(`^${source}((,${source})+)?$`);
};
export const KEY_VALUE_PAIRS_REGEX = regexWithOccurrencePattern(/\w+=\w+/);