Skip to content

The list of awesome regex (regular expressions) ready to use

License

Notifications You must be signed in to change notification settings

mmkjony/awesome-regex-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 

Repository files navigation

Awesome Regex (Regular Expressions) Awesome

A curated list of awesome Regex (Regular Expressions) ready to use

Test regex on https://regex101.com/#pcre

Table of Content

Information technology

Hex color

/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
String Match
#C0FF33
#000000
#fff
#ffffff
#FFFFFF

IP Address

/^((?:(?: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]?))*$/
String Match
192.168.1.1
255.255.255.0
8.8.8.8

MAC Address

/^(?:[0-9a-f]{2}[\-:]?){6}(?<![\-:])$/i
String Match
AA:BB:CC:DD:EE:FF
AA-BB-CC-DD-EE-FF
AA:BB-CC:DD-EE:FF
AABBCCDDEEFF
AA.BB.CC.DD.EE.FF
AA-BB-CC-DD-EE-GG
AA:BB:CC:DD:EE:FF:
AA:BB:CC:DD:EE:FF-

Mail

/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/
String Match
foo@bar.com
lol.foo@bar.com
foo@bar

URL

/^(((http|https|ftp):\/\/)?([[a-zA-Z0-9]\-\.])+(\.)([[a-zA-Z0-9]]){2,4}([[a-zA-Z0-9]\/+=%&_\.~?\-]*))*$/

Spotify track

/^https?:\/\/(?:open|play)\.spotify\.com\/track\/[\w\d]+$/i

Spotify playlist

/^https?:\/\/(?:open|play)\.spotify\.com\/user\/([\w\d]+)\/playlist\/[\w\d]+$/i

Soundcloud

/^https?:\/\/soundcloud\.com\/\S+\/\S+$/i
String Match
https://soundcloud.com/geierre/only-tonight

Deezer track/album/playlist

/^https?:\/\/(?:www\.)?deezer\.com\/(track|album|playlist)\/(\d+)$/

Youtube

/^https?:\/\/(?:(?:www|m)\.)?(?:youtube\.com\/watch(?:\?v=|\?.+?&v=)|youtu\.be\/)([a-z0-9_-]+)$/i
String Match
http://www.youtube.com/watch?v=dbB-mICjkQM
https://www.youtube.com/watch?v=dbB-mICjkQM
https://m.youtube.com/watch?v=dbB-mICjkQM
https://youtu.be/dbB-mICjkQM

Vimeo

/^https?:\/\/(?:www\.)?vimeo\.com.+?(\d+).*$/i
String Match
https://vimeo.com/58165438
http://vimeo.com/58165438

Dailymotion

/^https?:\/\/(?:www\.)?(?:dai\.ly\/|dailymotion\.com\/(?:.+?video=|(?:video|hub)\/))([a-z0-9]+)$/i
String Match
http://www.dailymotion.com/video/x3pu5i0

Facebook photo / video

/^https?:\/\/(?:www\.)?facebook\.com\/(?:(?:photo|video)\.php(?:\?v=|\?.+?&v=)|[a-z0-9._-]+\/videos\/)(\d+)\/?$/i

NERDZCrush

/^https?:\/\/(?:cdn\.)?media\.nerdz\.eu\/([a-z0-9_-]{12})(?:|\.[a-z0-9]{2,4})$/i

Imgur

/^https?:\/\/(?:www\.)?(?:i\.)?imgur\.com\/([a-z0-9_-]+)\.(?:gifv|webm)$/i
String Match
http://i.imgur.com/w59wsnu.gifv

GitHub profile / organization

/^https?:\/\/(www\.)?github\.com\/[a-z0-9]+$/i
String Match
https://github.com/OpenCode

Twitter status

/^https?:\/\/twitter.com\/[a-z0-9_]+\/status\/[0-9]+$/i
String Match
https://twitter.com/_opencode/status/690479102978035712

Text manipulation

Remove CDATA tags

/<!\[CDATA\[(.*)\]\]>/

About

The list of awesome regex (regular expressions) ready to use

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages