Python
url:http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+
email:r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"
IP地址:^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
Javascript
url:/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/
email:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[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,}))$/
ip地址:/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
Regex Cheat Sheet
Modifiers:
i | Perform case-insensitive matching |
g | Perform a global match |
Brackets:
[abc] | Match a single character a, b, or c |
[^abc] | Match any character except a, b, or c |
[A-z] | Match any character from uppercase A to lowercase z |
(ab|cd|ef) | Match either ab, cd, or ef |
(…) | Capture anything enclosed |
Metacharacters
^ | Start of line |
$ | End of line |
. | Match any character |
\w | Match a word chracter |
\W | Match a non-word character |
\d | Match a digit |
\D | Match any non-digit character |
\s | Match a whitespace character |
\S | Match a non-whitespace character |
\b | Match character at the beginning or end of a word |
\B | Match a character not at beginning or end of a word |
\0 | Match a NUL character |
\t | Match a tab character |
\xxx | Match a character specified by octal number xxx |
\xdd | Match a character specified by hexadecimal number dd |
\uxxxx | Match a Unicode character specified by hexadecimal number xxxx |