From ef43cbda9b7366d5e341ead1b954c0adac61dbe4 Mon Sep 17 00:00:00 2001 From: Ahmadullah mirza Date: Tue, 31 Dec 2024 20:09:45 +0530 Subject: [PATCH 1/5] Feat(data): Add JS regex match utility function to snippets --- public/data/javascript.json | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/public/data/javascript.json b/public/data/javascript.json index ac4d9ece..5aae2d71 100644 --- a/public/data/javascript.json +++ b/public/data/javascript.json @@ -935,5 +935,48 @@ "author": "realvishalrana" } ] + }, + { + "categoryName": "Regular expression", + "snippets": [ + { + "title": "Regex Match Utility Function", + "description": "Enhanced regular expression matching utility.", + "code": [ + "/**", + "* @param {string | number} input", + "* The input string to match", + "* @param {regex | string} expression", + "* Regular expression", + "* @param {string} flags", + "* Optional Flags", + "*", + "* @returns {array}", + "* [{", + "* match: '...',", + "* matchAtIndex: 0,", + "* capturedGroups: [ '...', '...' ]", + "* }]", + "*/", + "function regexMatch(input, expression, flags = 'g') {", + " let regex =", + " expression instanceof RegExp", + " ? expression", + " : new RegExp(expression, flags);", + " let matches = input.matchAll(regex);", + " matches = [...matches];", + " return matches.map((item) => {", + " return {", + " match: item[0],", + " matchAtIndex: item.index,", + " capturedGroups: item.length > 1 ? item.slice(1) : undefined,", + " };", + " });", + "}" + ], + "tags": ["javascript","regex"], + "author": "aumirza" + } + ] } ] From 10b68d7636a19c919023219a610b17363ff8ae4f Mon Sep 17 00:00:00 2001 From: Ahmadullah mirza Date: Tue, 31 Dec 2024 20:13:23 +0530 Subject: [PATCH 2/5] Feat(data:Js): Add utility function to convert strings to camelCase --- public/data/javascript.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/data/javascript.json b/public/data/javascript.json index 5aae2d71..2818c206 100644 --- a/public/data/javascript.json +++ b/public/data/javascript.json @@ -218,6 +218,20 @@ "tags": ["string", "case", "snake_case"], "author": "axorax" }, + { + "title": "Convert String to Camel Case", + "description": "Converts a given string into camelCase.", + "code": [ + "function toCamelCase(str) {", + " return str.replace(/\\W+(.)/g, (match, chr) => chr.toUpperCase());", + "}", + "", + "// Example usage:", + "console.log(toCamelCase('hello world test')); // Output: 'helloWorldTest'" + ], + "tags": ["string", "case", "camelCase"], + "author": "aumirza" + }, { "title": "Remove Vowels from a String", "description": "Removes all vowels from a given string.", From 60a66621a9db8a438b751a0eb40d4451970680fb Mon Sep 17 00:00:00 2001 From: Ahmadullah mirza Date: Tue, 31 Dec 2024 20:14:03 +0530 Subject: [PATCH 3/5] Feat(data:Js): Add utility function to convert strings to Title Case --- public/data/javascript.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/data/javascript.json b/public/data/javascript.json index 2818c206..3822af53 100644 --- a/public/data/javascript.json +++ b/public/data/javascript.json @@ -231,6 +231,20 @@ ], "tags": ["string", "case", "camelCase"], "author": "aumirza" + }, + { + "title": "Convert String to Title Case", + "description": "Converts a given string into Title Case.", + "code": [ + "function toTitleCase(str) {", + " return str.toLowerCase().replace(/\\b\\w/g, (s) => s.toUpperCase());", + "}", + "", + "// Example usage:", + "console.log(toTitleCase('hello world test')); // Output: 'Hello World Test'" + ], + "tags": ["string", "case", "titleCase"], + "author": "aumirza" }, { "title": "Remove Vowels from a String", From 791e02404f645accd8ea9837f4af018d77716829 Mon Sep 17 00:00:00 2001 From: Ahmadullah mirza Date: Tue, 31 Dec 2024 20:14:27 +0530 Subject: [PATCH 4/5] Feat(data:Js): Add utility function to convert strings to Pascal Case --- public/data/javascript.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/data/javascript.json b/public/data/javascript.json index 3822af53..7f616310 100644 --- a/public/data/javascript.json +++ b/public/data/javascript.json @@ -245,6 +245,20 @@ ], "tags": ["string", "case", "titleCase"], "author": "aumirza" + }, + { + "title": "Convert String to Pascal Case", + "description": "Converts a given string into Pascal Case.", + "code": [ + "function toPascalCase(str) {", + " return str.replace(/\\b\\w/g, (s) => s.toUpperCase()).replace(/\\W+(.)/g, (match, chr) => chr.toUpperCase());", + "}", + "", + "// Example usage:", + "console.log(toPascalCase('hello world test')); // Output: 'HelloWorldTest'" + ], + "tags": ["string", "case", "pascalCase"], + "author": "aumirza" }, { "title": "Remove Vowels from a String", From b436fb90139b1580680d5f1d83fe907ae9360085 Mon Sep 17 00:00:00 2001 From: Ahmadullah mirza Date: Tue, 31 Dec 2024 20:14:42 +0530 Subject: [PATCH 5/5] Feat(data:Js): Add utility function to convert strings to param-case --- public/data/javascript.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/data/javascript.json b/public/data/javascript.json index 7f616310..789c0e00 100644 --- a/public/data/javascript.json +++ b/public/data/javascript.json @@ -259,6 +259,20 @@ ], "tags": ["string", "case", "pascalCase"], "author": "aumirza" + }, + { + "title": "Convert String to Param Case", + "description": "Converts a given string into param-case.", + "code": [ + "function toParamCase(str) {", + " return str.toLowerCase().replace(/\\s+/g, '-');", + "}", + "", + "// Example usage:", + "console.log(toParamCase('Hello World Test')); // Output: 'hello-world-test'" + ], + "tags": ["string", "case", "paramCase"], + "author": "aumirza" }, { "title": "Remove Vowels from a String",