Improve string cleanup function
Replace special character with a space and reduce multiple spaces to one
This commit is contained in:
@@ -8,4 +8,7 @@
|
||||
|
||||
export const baseCleanup = (str: string) => str.toLowerCase().trim();
|
||||
|
||||
export const enhancedCleanup = (str: string): string => baseCleanup(str).replace(/[^a-zA-Z0-9]/g, '');
|
||||
export const enhancedCleanup = (str: string): string =>
|
||||
baseCleanup(str)
|
||||
.replace(/[^a-zA-Z0-9\\s]+/g, ' ')
|
||||
.trim();
|
||||
|
||||
Reference in New Issue
Block a user