-
Notifications
You must be signed in to change notification settings - Fork 16
/
regexes.txt
44 lines (39 loc) · 1.41 KB
/
regexes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# a sample from each important category of regex
# literal
hello
# complex literal
"GET /index.html HTTP/1.1" 500
# search pattern
Hi, M(?:r|s|rs). (.*?)!
# scraping
You have (?P<count>\d+) unread messages
# validator
^[a-zA-Z_][0-9a-zA-Z_]*$
# beast
\b((?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d))\b
# apache log parser
/^(\S+) \S+ \S+ \[(?P<date>[^\]]+)\] "(?P<http_method>[A-Z]+)[^"]*" \d+ \d+ "[^"]*" "(?P<user_agent>[^"]*)"$/m
# clean google groups email list
/^.*\((.*@.*)\)$/#\1/
/^[^\n#].*$//
# routes
url(r'^page/(?P<question_count>\d+)/(?P<url>.*)/$', views.PageView.as_view(), name='page-with-question-count'),
url(r'^page/(?P<url>.*)/$', views.PageView.as_view(), name='page'),
url(r'^tts/(?P<language>\w*)/(?P<phrase>[^/]*)/$', tts.views.TextToSpeechView.as_view(), name='tts'),
url(r'^tts/(?P<phrase>[^/]*)/$', tts.views.TextToSpeechView.as_view(), name='tts-en'),
# username
/^[a-z0-9_-]{3,16}$/
# password
/^[a-z0-9_-]{6,18}$/
# hex color
/^#?([a-f0-9]{6}|[a-f0-9]{3})$/
# url slug
/^[a-z0-9-]+$/
# email (wrong, duh)
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
# url (wrong, duh)
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
# 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]?)$/
# HTML tag
/^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/