Skip to content

BenenB/useful-regexes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 

Repository files navigation

useful-regexes

A rag-tag collection of Regexes, hopefully worth saving for future use

CONTRIBUTIONS WELCOME

Validation

  • Email

    • /^[\w]+[\.\w]*[\w]+@\w+\.{1}[\w]+\.?[\w]+$/
  • Filename

    • Based on characters restricted by windows
    • /^(?<name>[^\\\/:*?"<>|\s]+)\.(?<type>[^\\\/:*?"<>|\s]+)$/

Parsing

  • URL

    • /(?:(?<protocol>https?):\/\/)?(?<host>(?:(?:[\w\-\~]+\.)+[\w]+)|(?:localhost)){1}(?::(?<port>\d+))?(?<path>\/[\w\-\~\.\/]+)?(?:#(?<fragment>[\w\-\~]+))?(?:\?(?<query>[\w\-\~\=\&]+))?/
  • Flexible CLI ARGS

    • Matches cli flags & corresponding arguments, flexible to allow use of equals sign and also allow spaces in arg if enclosed in matching brackets
    • /-{1,2}(?<flag>\w+)(?:(?:(?=\s*=)\s*=\s*|\s+)(?<br>['"])?(?<arg>(?:(?!\k<br>)(?!-))(?:(?!\k<br>)(?(<br>)[^\n\r]|[^\s]))*)(?(<br>)\k<br>))?/

Misc

  • Find Images with empty or missing alt attributes
    • /<img (?:alt="" *)*(?:(?!alt)[-\d\w]+="[^"]*" *)*(?:alt="" *)*(?:(?!alt)[-\d\w]+="[^"]*" *)*(?:alt="" *)*\/?>/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published