Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added regex category, and few case change snippets in string manipulation JavaScript. #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Mathys-Gasnier merged 5 commits into quicksnip-dev:main from aumirza:main
Dec 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions public/data/javascript.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,62 @@
"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": "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": "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": "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",
"description": "Removes all vowels from a given string.",
Expand Down Expand Up @@ -935,5 +991,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"
}
]
}
]

AltStyle によって変換されたページ (->オリジナル) /