All Projects → jeffreyshen19 → Regex Snippets

jeffreyshen19 / Regex Snippets

Licence: cc0-1.0
Organized list of useful RegEx snippets

Projects that are alternatives of or similar to Regex Snippets

Awesome Devtools
🤖 A curated list of in-browser bookmarklets, tools, and resources for modern full-stack software engineers.
Stars: ✭ 184 (+68.81%)
Mutual labels:  list, regex
Htaccess
✂A collection of useful .htaccess snippets.
Stars: ✭ 11,830 (+10753.21%)
Mutual labels:  snippets, list
30 Seconds Of Swift Code
A Swift implementation of 30-seconds-of-code: A curated collection of useful Swift 4 snippets that you can understand in 30 seconds or less.
Stars: ✭ 476 (+336.7%)
Mutual labels:  snippets, list
Ncm R
R autocompletion for Neovim and vim 8 📝 📊 ⚡️
Stars: ✭ 102 (-6.42%)
Mutual labels:  snippets
Collection Document
Collection of quality safety articles. Awesome articles.
Stars: ✭ 1,387 (+1172.48%)
Mutual labels:  list
Glsnip
copy and paste across machines
Stars: ✭ 107 (-1.83%)
Mutual labels:  snippets
Awesome Nodejs
⚡ Delightful Node.js packages and resources
Stars: ✭ 43,231 (+39561.47%)
Mutual labels:  list
Cfp List
Конференции по фронтенду, принимающие доклады на русском языке
Stars: ✭ 101 (-7.34%)
Mutual labels:  list
Awesome Stock Resources
🌇 A collection of links for free stock photography, video and Illustration websites
Stars: ✭ 10,162 (+9222.94%)
Mutual labels:  list
Sketchup Ruby Api Tutorials
SketchUp Ruby API Tutorials and Examples
Stars: ✭ 105 (-3.67%)
Mutual labels:  snippets
Awesome Board Games
A curated list of awesome and exceptional board games. Please contribute!
Stars: ✭ 105 (-3.67%)
Mutual labels:  list
Dotfiles
This is a mirror from https://gitlab.com/andreyorst/dotfiles
Stars: ✭ 103 (-5.5%)
Mutual labels:  snippets
Awesome Static Website Services
📄 🛠 A curated list of awesome static websites services
Stars: ✭ 1,532 (+1305.5%)
Mutual labels:  list
Fuzz.txt
Potentially dangerous files
Stars: ✭ 1,382 (+1167.89%)
Mutual labels:  list
Gods
GoDS (Go Data Structures). Containers (Sets, Lists, Stacks, Maps, Trees), Sets (HashSet, TreeSet, LinkedHashSet), Lists (ArrayList, SinglyLinkedList, DoublyLinkedList), Stacks (LinkedListStack, ArrayStack), Maps (HashMap, TreeMap, HashBidiMap, TreeBidiMap, LinkedHashMap), Trees (RedBlackTree, AVLTree, BTree, BinaryHeap), Comparators, Iterators, …
Stars: ✭ 10,883 (+9884.4%)
Mutual labels:  list
Boswatch
Python Script to process input data from rtl_fm and multimon-NG - multiple Plugin support
Stars: ✭ 101 (-7.34%)
Mutual labels:  regex
Command Line Text Processing
⚡ From finding text to search and replace, from sorting to beautifying text and more 🎨
Stars: ✭ 9,771 (+8864.22%)
Mutual labels:  regex
Mal
MAL: A MyAnimeList Command Line Interface [BROKEN: BLAME MyAnimeList]
Stars: ✭ 104 (-4.59%)
Mutual labels:  list
Sublime Robot Framework Assistant
Robot Framework plugin for Sublime Text3
Stars: ✭ 103 (-5.5%)
Mutual labels:  snippets
Gopherlabs
The Ultimate Workshop Track for #golang Developer
Stars: ✭ 106 (-2.75%)
Mutual labels:  list

RegEx Snippets

Useful RegEx snippets that are categorized and searchable (see below)

  • Contributions are welcome! Please read our CONTRIBUTING, CODE_OF_CONDUCT, and LICENSE files to get started. RegEx snippet ideas are located in IDEAS.md.
  • Errors? Submit an issue, or even better, submit a PR fixing the issue!
  • RegEx snippets are either user-created, or picked from across the web.

Table of Contents

  • Dates
    • Match mm/dd/yyyy
    • Match mon/dd/yyyy
    • Match month names
  • Files
    • Match image filenames
  • Miscellaneous
    • Match city, state abbreviation
    • Match credit cards
    • Match email addresses
    • Match US Phone Numbers
    • Match valid hexadecimal colors
    • Match social security number
    • Match ZIP Codes (5 digit and 9 digit)
  • Numbers
    • Match dollar signs and comma separators in a number
    • Matching leading zeroes
  • Strings
    • Match new lines
    • Match strong passwords (At least one lower case, one upper case, one number, one special character, and 10 characters long)
    • Match usernames (alphanumeric string of a certain length)
  • Web
    • Extract URL from an anchor tag
    • Match all content within a specific HTML tag
    • Match all HTML tags
    • Match IPv4 Addresses
    • Match Twitter usernames
    • Match URLs
    • Match URL safe strings
    • Match URL slugs

Snippets

Dates

Match mm/dd/yyyy
Accepts mm/dd/yyyy, mm-dd-yyyy, or mm.dd.yyyy and doesn't care about leading zeroes.

/^[0-3]?[0-9](\/|\.|-)[0-3]?[0-9](\/|\.|-)[1-9]\d{3}$/gi

Match mon/dd/yyyy
Accepts mon/dd/yyyy, mon-dd-yyyy, or mon.dd.yyyy and doesn't care about leading zeroes or case. For example, will match "jan/10/2017"

/^(jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec)(\/|\.|-)[0-3]?[0-9](\/|\.|-)[1-9]\d{3}$/gi

Match month names
Accepts month names (both full and abbreviated), and doesn't care about case. For example, it will match "January" and "jan".

/^(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;

Files

Match image filenames

/^.+\.(jpg|jpeg|png|gif|bmp|svg)$/gi

Miscellaneous

Match city, state abbreviation (Matches "Los Angeles, CA" for example)

/[a-zA-Z\s]*, [A-Z][A-Z]/

Match credit cards (Make sure to strip the string of all commas, spaces, etc. before matching)
Amex:

/^3[47][0-9]{13}$/

Discover:

/^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$/

Mastercard:

/^5[1-5][0-9]{14}$/

Visa:

/^4[0-9]{12}(?:[0-9]{3})?$/

Visa Mastercard:

/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14})$/

Match email addresses

/^(([^<>()\[\]\\.,;:\[email protected]"]+(\.[^<>()\[\]\\.,;:\[email protected]"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i

Match US Phone Numbers
Matches ###-###-####, (###) ###-####, and ### ### ####

/^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$/

Match valid hexadecimal colors

/^#([0-9a-f]{3}$|[0-9a-f]{6}$)/i

Match social security number
Matches ###-##-####

/^[0-9]\{3\}-[0-9]\{2\}-[0-9]\{4\}$/

Match ZIP Codes (5 digit and 9 digit)

/^[0-9]{5}(-[0-9]{4})?$/

Numbers

Match dollar signs and comma separators in a number: This can be used to strip a number string into an actual number.

/(\$|\,)/g

Matching leading zeroes:

/^0{2,}/g

Strings

Match new lines

/[\r\n]|$/g

Match strong passwords (At least one lower case, one upper case, one number, one special character, and 10 characters long):

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[[email protected]$!%*?&_])[A-Za-z\[email protected]$!%*?&_]{10,}$/

Match usernames (alphanumeric string of a certain length):
Replace MIN_CHARS and MAX_CHARS with the minimum and maximum length of the username, respectively.

/^[a-z0-9]{MIN_CHARS,MAX_CHARS}$/i

Web

Extract URL from an anchor tag
For example, if str = "<a href = 'https://www.google.com' ></a>", this RegEx would return "https://www.google.com".

str.match(/<a\s+(?:[^>]*?\s+)?href ?= ?["']([^'^"]*)["'][^>]*>/i)[1]

Match all content within a specific HTML tag (Replace "p" with whatever tag you want)

/<p>(\n|.)*<\/p>/gi

Match HTML tags

/<\/?[^>]+>/g

Match IPv4 Addresses

/^((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]?)$/

Match Twitter Usernames

/^@?(\w){1,15}$/

Match URLs

/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w][email protected])?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w][email protected])[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/

Match URL safe strings

/^[a-zA-Z0-9_-]*$/

Match URL Slug

/^[a-z0-9-_]+$/i
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].