├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── contribution_request.md │ └── feature_request.md └── PULL_REQUEST_TEMPLATE.md ├── .vscode └── launch.json ├── .vscodeignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── icon.png ├── package.json ├── regexsnippets-1.0.2.vsix └── regexsnippets.code-snippets /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behavior to automatically normalize line endings. 2 | * text=auto 3 | 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/contribution_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Snippet Request 3 | about: Suggest a new snippet which you would like to add to this repository 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **What is your Snippet About?** 11 | A clear and concise description of what your idea is 12 | 13 | **Add the code snippet with explanation** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Has this code snippet been tested?** 17 | Has this been tested yet? 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the contribution request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Please check if the PR fulfills these requirements: 2 | 3 | * [ ] The PR title and message describe the solution briefly. 4 | * [ ] Documentation has been updated/added if relevant 5 | 6 | ### What is the current behavior? 7 | 8 | 9 | ### What is the new behavior? 10 | 11 | ### Other information? 12 | 13 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ] 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "regexsnippets" extension will be documented in this file. 4 | 5 | ## Changes 6 | 7 | - Initial release 8 | 9 | ### [1.0.2] - 2021-08-20 10 | 11 | #### Added 12 | - 11 new Regex Snippets 13 | - Language Support for 10 new languages 14 | 15 | #### Changed 16 | - Fixed Indentations -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to vscode-regex-snippets 2 | 3 | A big welcome and thank you for considering contributing to 4 | vscode-regex-snippets projects! It’s people like you that make it a reality for 5 | users in our community. 6 | 7 | Reading and following these guidelines will help us make the contribution 8 | process easy and effective for everyone involved. It also communicates that you 9 | agree to respect the time of the developers managing and developing these open 10 | source projects. In return, we will reciprocate that respect by addressing your 11 | issue, assessing changes, and helping you finalize your pull requests. 12 | 13 | ## Quicklinks 14 | 15 | - [Code of Conduct](#code-of-conduct) 16 | - [Getting Started](#getting-started) 17 | - [Issues](#issues) 18 | - [Pull Requests](#pull-requests) 19 | 20 | ## Code of Conduct 21 | 22 | We take our open source community seriously and hold ourselves and other 23 | contributors to high standards of communication. By participating and 24 | contributing to this project. 25 | 26 | ## Getting Started 27 | 28 | Contributions are made to this repo via Issues and Pull Requests (PRs). A few 29 | general guidelines that cover both: 30 | 31 | - Search for existing Issues and PRs before creating your own. 32 | - If you've never contributed before, see the first timer's guide for resources 33 | and tips on how to get started. 34 | 35 | ### Issues 36 | 37 | Issues should be used to report problems with the code snippets, request a new 38 | feature, or to discuss potential changes before a PR is created. 39 | 40 | ### Pull Requests 41 | 42 | PRs to our repo are always welcome. 43 | 44 | 1. Fork the repository to your own Github account 45 | 2. Clone the project to your machine 46 | 3. Create a branch locally with a succinct but descriptive name 47 | 4. Commit changes to the branch 48 | 5. Following any formatting and testing guidelines specific to this repo 49 | 6. Push changes to your fork 50 | 7. Open a PR in our repository and follow the PR template so that we can 51 | efficiently review the changes. 52 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Monish Basaniwal 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |
Hello
`) | 1 Input: `tag_name` for the HTML Tag you want to search for | 69 | | 22 | `!valhtmltag` | Validates if the given string has either a opening or closing HTML tag (Does not verify if the HTML Tag exists) | N/A | 70 | | 23 | `!valtwitter` | Twitter Username Validation | N/A | 71 | | 24 | `!valurl` | URL Validation | N/A | 72 | | 25 | `!valgooglesyn` | Google Search Syntax Validation | N/A | 73 | | 26 | `!extcssmedia` | Extract properties and values from CSS Media Queries | N/A | 74 | | 27 | `!exthtmlcomms` | Strip all comments from a HTML Code Block | N/A | 75 | | 28 | `!extcss` | Extract Individual CSS Properties from the given Code Block | N/A | 76 | | 29 | `!extytid` | Extract Video ID from a valid Youtube Video Link | N/A | 77 | | 30 | `!extimgsrc` | Extract image source links from HTML Image Tags | N/A | 78 | | 31 | `!valbase64` | Base64 String Validation | N/A | 79 | | 32 | `!septhousand` | Seperates the digits in the string to thousand with commas | N/A | 80 | | 33 | `!valchars` | Validate if the the string contains atleast one occurrence of the Character to be searched | 1 Input: `chars_to_be_searched` | 81 | | 34 | `!valspaces` | Convert multiple spaces to single spaces between each word in a string | N/A | 82 | | 35 | `!extsqrbracks` | Extract Square Brackets and the content between them | N/A | 83 | | 36 | `!valalpnum` | Non-Alphanumeric Characters Validation | N/A | 84 | | 37 | `!extlogs` | Extract native Javascript console and AngularJS \$log log warn or info that are NOT comments / commented out | N/A | 85 | | 38 | `!extbrackscont` | Extract all brackets and the content between them | N/A | 86 | | 39 | `!addlinktag` | Adds Link Tags to all the strings that start with http or https (Full Function Provided) | N/A | 87 | | 40 | `!findocurrences` | Provides a function to calculate the number of times the provided character(s) have appeared in the string (Returns 0 when no ocurrences found) | 2 Inputs: `string` on which the match should be applied and `string_to_search` for the string to be searched for | 88 | | 41 | `!valuuidv1` | UUID v1 Validation | N/A | 89 | | 42 | `!valuuidv2` | UUID v2 Validation | N/A | 90 | | 43 | `!valuuidv3` | UUID v3 Validation | N/A | 91 | | 44 | `!valuuidv4` | UUID v4 Validation | N/A | 92 | | 45 | `!valuuidv5` | UUID v5 Validation | N/A | 93 | | 46 | `!extquotes` | Extracts any text between quotations (Works with nested quotes too) | N/A | 94 | | 47 | `!splitnchunks` | Splits the given string to n-sized chunks even if its size is not an exact multiple | 1 Input: `end_size` for chunk size | 95 | | 48 | `!valzip` | Zip Code(5 or 9 digits only) Validation | N/A | 96 | | 49 | `!valendswith` | Check if the provided string ends with the given Character | 1 Input: `character` which the string should end with | 97 | | 50 | `!extdomain` | Extract the domain from a valid URL string | N/A | 98 | | 51 | `!tocamel` | Returns a function which converts the given string to camelCase | 1 Input: `string` to be replaced | 99 | | 52 | `!valjwt` | Validates if the given string is a valid JSON Web Token (JWT) | N/A | 100 | | 53 | `!valjson` | Validates if the given string is a valid Non-array JSON | N/A | 101 | | 54 | `!valspecialusername` | Validates if the given string is in the form of test@test | N/A | 102 | | 55 | `!multispace` | Replaces all the spaces in the given string with a single space | N/A | 103 | | 56 | `!nonalphanumeric` | Replaces all the non-alphanumeric characters in the given string with a single space | N/A | 104 | | 57 | `!blankline` | Validates if the given string is blank line | N/A | 105 | | 58 | `!positiveint` | Checks if the given string is a valid positive integer | N/A | 106 | | 59 | `!positivedecimal` | Validates if the given string is a valid positive decimal | N/A | 107 | | 60 | `!positivedecimal1` | Validates if the given string is a valid positive decimal with a single decimal digit | N/A | 108 | | 61 | `!ssn` | Validates if the given string is a valid Social Security Number | N/A | 109 | | 62 | `!valdate` | Validate if the given string is a valid date | N/A | 110 | | 63 | `!replacefont` | Replaces all the font tags in the given string with a single space | N/A | 111 | 112 | ### Installation 113 | 114 | Requires VS Code Version `1.20.0` atleast 115 | 116 | 1. Install Visual Studio Code 1.10.0 or higher 117 | 2. Launch Code 118 | 3. From the command palette `Ctrl+Shift+P` (Windows, Linux) or 119 | `Cmd+Shift+P` (OSX) 120 | 4. Select `Install Extension` 121 | 5. Choose the extension 122 | 6. Reload Visual Studio Code 123 | 7. Optionally find the extension file 124 | [here](https://github.com/monizb/vscode-regex-snippets/blob/master/regexsnippets-1.0.2.vsix) 125 | , launch VS Code , Goto the extensions tab click the 3 dots on top, Click 126 | install from VSIX File, Choose the downloaded file and done! 127 | 128 | ### Contribution 129 | 130 | Any and every contribution to this repoitory is welcomed, if you would like to 131 | add new features, file a bug report or make contribution, please first create an 132 | issue using the appropriate template. 133 | 134 | ### Author 135 | 136 | Monish Basaniwal 137 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monizb/vscode-regex-snippets/a8fc796faaffa5fd90d9b617d50f199d51f029d7/icon.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "regexsnippets", 3 | "displayName": "Regex Snippets", 4 | "description": "Easily Insert Popular Regex Codes Without Memorising Anything!", 5 | "version": "1.0.2", 6 | "publisher": "Monish", 7 | "icon": "icon.png", 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/monizb/vscode-regex-snippets" 11 | }, 12 | "engines": { 13 | "vscode": "^1.20.0" 14 | }, 15 | "categories": [ 16 | "Snippets" 17 | ], 18 | "contributes": { 19 | "snippets": [ 20 | { 21 | "language": "javascript", 22 | "path": "./regexsnippets.code-snippets" 23 | }, 24 | { 25 | "language": "javascriptreact", 26 | "path": "./regexsnippets.code-snippets" 27 | }, 28 | { 29 | "language": "typescript", 30 | "path": "./regexsnippets.code-snippets" 31 | }, 32 | { 33 | "language": "javascriptangular", 34 | "path": "./regexsnippets.code-snippets" 35 | }, 36 | { 37 | "language": "typescriptreact", 38 | "path": "./regexsnippets.code-snippets" 39 | }, 40 | { 41 | "language": "typescriptangular", 42 | "path": "./regexsnippets.code-snippets" 43 | }, 44 | { 45 | "language": "html", 46 | "path": "./regexsnippets.code-snippets" 47 | }, 48 | { 49 | "language": "css", 50 | "path": "./regexsnippets.code-snippets" 51 | }, 52 | { 53 | "language": "vue", 54 | "path": "./regexsnippets.code-snippets" 55 | }, 56 | { 57 | "language": "vue-html", 58 | "path": "./regexsnippets.code-snippets" 59 | }, 60 | { 61 | "language": "vue-template", 62 | "path": "./regexsnippets.code-snippets" 63 | }, 64 | { 65 | "language": "vue-ts", 66 | "path": "./regexsnippets.code-snippets" 67 | }, 68 | { 69 | "language": "python", 70 | "path": "./regexsnippets.code-snippets" 71 | } 72 | ] 73 | } 74 | } -------------------------------------------------------------------------------- /regexsnippets-1.0.2.vsix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monizb/vscode-regex-snippets/a8fc796faaffa5fd90d9b617d50f199d51f029d7/regexsnippets-1.0.2.vsix -------------------------------------------------------------------------------- /regexsnippets.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Validate E-Mail Address": { 3 | "prefix": "!valemail", 4 | "body": "/^[A-Z0-9!#$%&'*+/=?^_`{|}~-][A-Z0-9!#$%&'*+/=?^_`{|}~.-]*[A-Z0-9!#$%&'*+/=?^_`{|}~-]@[A-Z0-9][A-Z0-9-]*\\.[A-Z0-9-]*[A-Z0-9]$/igm", 5 | "description": "Validates the given email address" 6 | }, 7 | "Validate Hexadecimal Color Value": { 8 | "prefix": "!valhexcol", 9 | "body": "^#(?:[0-9a-fA-F]{3}){1,2}$", 10 | "description": "Validates the given string to check if it is a valid Hexadecimal Color Value" 11 | }, 12 | "Password Strength Validator": { 13 | "prefix": "!valpass", 14 | "body": "/^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&_])[A-Za-z\\d$@$!%*?&_]{${1:minlength},${2:maxlength}}$/", 15 | "description": "Validates the provided password to check if it contains atleast 1 Upper Case, 1 Lower Case, 1 Special Char, 1 Number. The min value represents the minimum length and max represents maximum length" 16 | }, 17 | "Validate ISBN Number": { 18 | "prefix": "!valisbn", 19 | "body": "/\\b(?:ISBN(?:: ?| ))?((?:97[89])?\\d{9}[\\dx])\\b/i", 20 | "description": "Validates the given ISBN Number" 21 | }, 22 | "Validate IPV4 Address": { 23 | "prefix": "!valipv4", 24 | "body": "/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b/", 25 | "description": "Validates the given IPV4 address" 26 | }, 27 | "Validate IPV6 Address": { 28 | "prefix": "!valipv6", 29 | "body": "(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))", 30 | "description": "Validates the given IPV6 address" 31 | }, 32 | "Validate Date In mm/dd/yy": { 33 | "prefix": "!valmmddyy", 34 | "body": "/^[0-3]?[0-9](/|\\.|-)[0-3]?[0-9](/|\\.|-)[1-9]\\d{3}$/gi", 35 | "description": "Validate the given date in dd/mm/yy (Does not care about the separator or the leading zeros)" 36 | }, 37 | "Validate Date In mon/dd/yyyy": { 38 | "prefix": "!valmonddyyyy", 39 | "body": "/^(jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec)(/|\\.|-)[0-3]?[0-9](/|\\.|-)[1-9]\\d{3}$/gi", 40 | "description": "Validates the given date in mon/dd/yyyy format (Ex: jan/23/2019)" 41 | }, 42 | "Validate Month Name": { 43 | "prefix": "!valmonth", 44 | "body": "/^(jan(uary)?|feb(ruary)?|(mar)?ch|(apr)?il|may|(jun)?e|(jul)?y|(aug)?ust|sep(tember)?|sept|(oct)?ober|(nov)?ember|(dec)?ember)$/i;", 45 | "description": "Validates month name both in full and abbreviated form (Ex: February or Feb)" 46 | }, 47 | "Extract Price From String": { 48 | "prefix": "!extprice", 49 | "body": "(\\\\${1:currency_symbol}\\s?[0-9,]+(\\.[0-9]{2})?)", 50 | "description": "Extract price value from any string (Add your currency symbol in the marked area)" 51 | }, 52 | "Parse 'To' From E-mail Header": { 53 | "prefix": "!parehead", 54 | "body": "/\\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\\.)+[A-Z]{2,6}\\b/i", 55 | "description": "Parse an email header and retrieve 'To' value from it" 56 | }, 57 | "Validate Facebook Profile Link": { 58 | "prefix": "!valfblink", 59 | "body": "(?:http:\\/\\/)?(?:www\\.)?facebook\\.com/(?:(?:\\w)*#!/)?(?:pages/)?(?:[\\w\\-]*/)*([\\w\\-]*)", 60 | "description": "Validate the given facebook profile link" 61 | }, 62 | "Validate Credit Card Number": { 63 | "prefix": "!valcc", 64 | "body": "^(?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\d{3})\\d{11})$", 65 | "description": "Validates Credit Card Number (Does'nt check for fake numbers) Supported Cards: Visa, MasterCard, American Express, Diners Club, Discover, and JCB" 66 | }, 67 | "Validate Alphanumeric Username": { 68 | "prefix": "!valusername", 69 | "body": "/^[a-z0-9]{${1:MIN_CHARS},${2:MAX_CHARS}}$/i", 70 | "description": "Simple Regex to validate an alphanumeric string based on the max and min length values" 71 | }, 72 | "Extract URL From String": { 73 | "prefix": "!exturl", 74 | "body": "(http|ftp|https):\\/\\/([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])?", 75 | "description": "Extract an URL from any string (With HTTP)" 76 | }, 77 | "Get Internet Explorer Version": { 78 | "prefix": "!getiever", 79 | "body": "^.*MSIE [5-8](?:\\.[0-9]+)?(?!.*Trident/[5-9]\\.0).*$", 80 | "description": "Get the version of Internet Explorer Being Used (To be used with a browser agent)" 81 | }, 82 | "Validate Image Filenames": { 83 | "prefix": "!valimage", 84 | "body": "/^.+\\.(${1:jpg|jpeg|png|gif|bmp|svg})$/gi", 85 | "description": "Validate the name of the image file (delete the names which are not requrired" 86 | }, 87 | "Validate Words With Abbreviations": { 88 | "prefix": "!valcityabbr", 89 | "body": "/[a-zA-Z\\s]*, [A-Z][A-Z]/", 90 | "description": "Validate words with abbreviated first 2 letters (Ex: California, CA)" 91 | }, 92 | "Validate US Phone Numbers": { 93 | "prefix": "!valusphone", 94 | "body": "/^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]\\d{3}[\\s.-]\\d{4}$/", 95 | "description": "Validate US Phone Numbers" 96 | }, 97 | "Validate Social Security Number": { 98 | "prefix": "!valssn", 99 | "body": "/^[0-9]\\{3\\}-[0-9]\\{2\\}-[0-9]\\{4\\}$/", 100 | "description": "Validate the given Social Security Number" 101 | }, 102 | "Validate Zip Codes (5 or 9 digits)": { 103 | "prefix": "!valzip", 104 | "body": "/^[0-9]{5}(-[0-9]{4})?$/", 105 | "description": "Validate the given Zip Code(5 or 9 digits only)" 106 | }, 107 | "Match Anything Between HTML Tags": { 108 | "prefix": "!valhtmlcont", 109 | "body": "/<${1:tag_name}>(\\n|.)*${1:tag_name}>/gi", 110 | "description": "Will verify if the provided string contains that HTML tag with any content between them" 111 | }, 112 | "Validate HTML Tag": { 113 | "prefix": "!valhtmltag", 114 | "body": "/?[^>]+>/g", 115 | "description": "Will verify if the provided string has either opening or closing html tags (Does not verify the valdity of the HTML Tag)" 116 | }, 117 | "Validate Twitter Username": { 118 | "prefix": "!valtwitter", 119 | "body": "/^@?(\\w){1,15}$/", 120 | "description": "Validates if the given string is a valid twitter username" 121 | }, 122 | "Validate URL": { 123 | "prefix": "!valurl", 124 | "body": "/^(?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:[/?#]\\S*)?$/i", 125 | "description": "Validates if the given string is a valid URL" 126 | }, 127 | "Validate Google Search Syntax": { 128 | "prefix": "!valgooglesyn", 129 | "body": "/([+-]?(?:'.+?'|\".+?\"|[^+\\- ]{1}[^ ]*))/g", 130 | "description": "Validates if the provided string is a valid google search syntax" 131 | }, 132 | "Extract Media Query Properties": { 133 | "prefix": "!extcssmedia", 134 | "body": "/@media([^{]+)\\{([\\s\\S]+?})\\s*}/g", 135 | "description": "Extract properties and values from CSS Media Queries" 136 | }, 137 | "Remove HTML Comments From Code Block": { 138 | "prefix": "!exthtmlcomms", 139 | "body": "", 140 | "description": "Strip all the comments from a HTML Code Block" 141 | }, 142 | "Extract CSS Properties And Values": { 143 | "prefix": "!extcss", 144 | "body": "^\\s*[a-zA-Z\\-]+\\s*[:]{1}\\s[a-zA-Z0-9\\s.#]+[;]{1}", 145 | "description": "Extract individual CSS Properties from the given string" 146 | }, 147 | "Extract Youtube Video ID From URL": { 148 | "prefix": "!extytid", 149 | "body": "/http:\\/\\/(?:youtu\\.be/|(?:[a-z]{2,3}\\.)?youtube\\.com/watch(?:\\?|#\\!)v=)([\\w-]{11}).*/gi", 150 | "description": "Extract the video ID from a valid Youtube Link" 151 | }, 152 | "Extract Image Source From Img Tag": { 153 | "prefix": "!extimgsrc", 154 | "body": "\\< *[img][^\\>]*[src] *= *[\"\\']{0,1}([^\"\\'\\ >]*)", 155 | "description": "Extract the image's source from the provided HTML code block" 156 | }, 157 | "Validate A Base64 String": { 158 | "prefix": "!valbase64", 159 | "body": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", 160 | "description": "Validate if the given string is Base64 compliant" 161 | }, 162 | "Extract Domain Name From URL": { 163 | "prefix": "!extdomain", 164 | "body": "/https?:\\/\\/(?:[-\\w]+\\.)?([-\\w]+)\\.\\w+(?:\\.\\w+)?/?.*/i", 165 | "description": "Extract the domain from a valid URL string" 166 | }, 167 | "Seperate Thousands": { 168 | "prefix": "!septhousand", 169 | "body": "/\\d{1,3}(?=(\\d{3})+(?!\\d))/g", 170 | "description": "Seperates the given numeric string with commas in thousands" 171 | }, 172 | "Validate If Word/Char Exists": { 173 | "prefix": "!valchars", 174 | "body": "/${1: chars_to_be_searched}/", 175 | "description": "Check if the string contains atleast one occurence of the provided search chars" 176 | }, 177 | "Reduce Multiple Space To Single Space": { 178 | "prefix": "!valspaces", 179 | "body": "/\\s\\s+/g, ' '", 180 | "description": "Converts multiple spaces to single spaces between all words in the given string" 181 | }, 182 | "Extract Text Between Square Brackets": { 183 | "prefix": "!extsqrbracks", 184 | "body": "\\[([^]]+)\\]", 185 | "description": "Extract the square brackets and the text between them from a string" 186 | }, 187 | "Remove Alphanumeric Characters": { 188 | "prefix": "!valalpnum", 189 | "body": "/[^A-Za-z0-9 ]/", 190 | "description": "Validate the given string for Non-Alphanumeric Characters" 191 | }, 192 | "Extract JS/Angular Logs": { 193 | "prefix": "!extlogs", 194 | "body": "/^(\\s*)?[^/]{0,2}((\\$log|console)\\.(warn|log|info))(.*)$/gmi", 195 | "description": "Regular Expression to find native Javascript console and AngularJS $log log warn or info that are NOT comments / commented out" 196 | }, 197 | "Extract All Brackets With Contents": { 198 | "prefix": "!extbrackscont", 199 | "body": "/\\s*\\([^)]*\\)/', '", 200 | "description": "Extract all brackets and the content between them from a given string" 201 | }, 202 | "Add Links Tags To Strings That Are URLs": { 203 | "prefix": "!addlinktag", 204 | "body": "str.replace(/((http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?)/gi, '$1');", 205 | "description": "Adds Link Tags to all the strings that start with http or https (Full Function Provided)" 206 | }, 207 | "Count The Number Of Ocurrences Of Chars In A String": { 208 | "prefix": "!findocurrences", 209 | "body": "(${1: string}.match(/${2: string_to_search}/g) || []).length;", 210 | "description": "Provides a function to calculate the number of times the provided character(s) have appeared in the string (Returns 0 when no ocurrences found)" 211 | }, 212 | "Validate UUID V1": { 213 | "prefix": "!valuuidv1", 214 | "body": "/^[0-9A-F]{8}-[0-9A-F]{4}-[1][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i", 215 | "description": "Validates if the code is a valid UUID v1 code" 216 | }, 217 | "Validate UUID V2": { 218 | "prefix": "!valuuidv2", 219 | "body": "/^[0-9A-F]{8}-[0-9A-F]{4}-[2][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i", 220 | "description": "Validates if the code is a valid UUID v2 code" 221 | }, 222 | "Validate UUID V3": { 223 | "prefix": "!valuuidv3", 224 | "body": "/^[0-9A-F]{8}-[0-9A-F]{4}-[3][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i", 225 | "description": "Validates if the code is a valid UUID v3 code" 226 | }, 227 | "Validate UUID V4": { 228 | "prefix": "!valuuidv4", 229 | "body": "/^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i", 230 | "description": "Validates if the code is a valid UUID v4 code" 231 | }, 232 | "Validate UUID V5": { 233 | "prefix": "!valuuidv5", 234 | "body": "/^[0-9A-F]{8}-[0-9A-F]{4}-[5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i", 235 | "description": "Validates if the code is a valid UUID v5 code" 236 | }, 237 | "Extract Text Between Quotes": { 238 | "prefix": "!extquotes", 239 | "body": "([\"'])(?:(?=(\\?))\\2.)*?\\1", 240 | "description": "Extracts any text between quotations (Works with nested quotes too)" 241 | }, 242 | "Split String To n sized chunks": { 243 | "prefix": "!splitnchunks", 244 | "body": "/.{1,${1: end_size}}/g", 245 | "description": "Splits the given string to n-sized chunks even if its size is not an exact multiple" 246 | }, 247 | "Validate if the string ends with a particular character": { 248 | "prefix": "!valendswith", 249 | "body": "/.*[${1: character}]$/", 250 | "description": "Checks if the provided string ends with the provided character" 251 | }, 252 | "Convert to camelCase": { 253 | "prefix": "!tocamel", 254 | "body": "${1: string}.replace(/(?:^\\w|[A-Z]|\b\\w)/g, function(word, index) {return index === 0 ? word.toLowerCase() : word.toUpperCase();}).replace(/\\s+/g, '');", 255 | "description": "Returns a function which converts the given string to camelCase" 256 | }, 257 | "Balanced Paranthesis Validation": { 258 | "prefix": "!valbracks", 259 | "body": "\\((?>\\((?