const restrictString = (str: string): string => str.match(/[ab]/g)?.join('') || ''
Is there a way to restrict a string to only contain the characters 'a' and 'b' in a one-liner function?
I am aware that this can be achieved using an enum, but I prefer using a concise solution.