Comman Regex
Password
^(?=.[A-Z].[A-Z])(?=.[!@#$&])(?=.[0-9].[0-9])(?=.[a-z].[a-z].*[a-z]).{8}$
Hex
#([a-fA-F] | [0-9]){3, 6} |
/[A-Z0-9._%+-]+@[A-Z0-9-]+.+.[A-Z]{2,4}/igm
IPV4 Address
/\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/ |
IPV6 Address
(([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])) |
x.xxx
/\d{1,3}(?=(\d{3})+(?!\d))/g
Add HTTPS
if (!s.match(/^[a-zA-Z]+:\/\//)) { s = ‘http://’ + s; }
Get hostname from URL
/https?:\/\/(?:[-\w]+.)?([-\w]+).\w+(?:.\w+)?\/?.*/i
Phone number
^+?\d{1,3}?[- .]?(?(?:\d{2,3}))?[- .]?\d\d\d[- .]?\d\d\d\d$
Space (start & end)
^[ \s]+ | [ \s]+$ |
Get img resource
< [img][^>][src] = *["']{0,1}([^"'\ >])
DD/MM/YYYY
^(?:(?:31(\/ | - | .)(?:0?[13578] | 1[02]))\1 | (?:(?:29 | 30)(\/ | - | .)(?:0?[1,3-9] | 1[0-2])\2))(?:(?:1[6-9] | [2-9]\d)?\d{2})$ | ^(?:29(\/ | - | .)0?2\3(?:(?:(?:1[6-9] | [2-9]\d)?(?:0[48] | [2468][048] | [13579][26]) | (?:(?:16 | [2468][048] | [3579][26])00))))$ | ^(?:0?[1-9] | 1\d | 2[0-8])(\/ | - | .)(?:(?:0?[1-9]) | (?:1[0-2]))\4(?:(?:1[6-9] | [2-9]\d)?\d{2})$ |
Youtube
/https?:\/\/(?:youtu.be\/ | (?:[a-z]{2,3}.)?youtube.com\/watch(?:\? | #!)v=)([\w-]{11}).*/gi |
ISBN
/\b(?:ISBN(?:: ? | ))?((?:97[89])?\d{9}[\dx])\b/i |
CSS
^\s[a-zA-Z-]+\s[:]{1}\s[a-zA-Z0-9\s.#]+[;]{1}
Remove HYML comment
Facebook URL page
/(?:http:\/\/)?(?:www.)?facebook.com\/(?:(?:\w)#!\/)?(?:pages\/)?(?:[\w-]\/)([\w-])/
Internet Explorer version
^.MSIE 5-8?(?!.Trident\/[5-9].0).*$
Refer https://www.hongkiat.com/blog/regex-web-developers/