\d : a digit, eg. 0, 1, 2, 3, 4
\s : whitespace, eg. space character, \t tab, \n newline
[a-z] : any character between 'a' and 'z' inclusive
[0-9] : any character between '0' and '9' inclusive
Groups can be used to isolate certain sub-patterns within the overall string
\ : escape the preceding character, eg. \$ or \\
. : any character, excluding a newline
^ : beginning of string
$ : end of string
| : or, matches patterns on either side
+ : one, or more of the preceding character or set
* : zero, or more of the preceding character or set
? : zero, or one of the preceding character or set
{n} : n occurrences of the preceding character or set
{m,n} : m, to n, occurrences of the preceding character or set
I|i : case insensitive match
G|g : global, or greedy match
M|m : multiline search, ie. pattern spans newlines
>>> s = "http://map.com/?lon=103.853177&lat=1.280676&zoom=12"
>>> m = re.match(".+lon=(?P<lng>\d+\.\d+)&.*lat=(?P<lat>\d+\.\d+)&.*", s)
>>> m.groupdict()
{'lat': '1.280676', 'lng': '103.853177'}
> var s = "http://map.com/?lon=103.853177&lat=1.280676&zoom=12
> s.match(/.+lon=(\d+\.\d+)&.*lat=(\d+\.\d+).*/)
["http://map.com/?lon=103.853177&lat=1.280676&zoom=12", "103.853177", "1.280676"]
\d : all digits, ie. [0-9]
\D : characters EXCLUDING [0-9]
\s : whitespace characters, eg. newline (\n, \r\n), tabs (\t), space
\S : characters EXCLUDING \s
[a-zA-Z] : all English letters in upper and lowercase
[!@#$%^&*()] : characters typed using Shift-<number>
>>> a
'[{"two": "public", "one": "secret"}, {"two": "guava", "one": "banana"}]'
>>> re.findall("\"two\": \"(.+)\"", a)
['public", "one": "secret"}, {"two": "guava", "one": "banana']
>>> re.findall("\"two\": \"([^\"]+)\"", a)
['public', 'guava']
.+ : one or more non-newline characters
lon= : the literal string, "lon="
(\d+\.\d+): group, >1 digits, a literal dot, >1 digits
& : a literal '&' character
.* : zero or more non-newline characters
lat= : the literal string, 'lat='
(\d+\.\d+): group, >1 digits, a literal dot, >1 digits
.* : zero or more non-newline characters
^[R|P] : string must begin with 'R' or 'P'
\d{6} : 6 digits in a row
[A-Z] : one instance of any character in the range A-Z
$ : end of string
.* : zero or more non-newline characters
\. : literal '.' character
.(png|jpg|jpeg|gif)$ : ends with either of 'png', 'jpg', 'jpeg', 'gif'
| : OR
^https://graph.face..: begins with Facebook Graph URL ...
\d+ : has a sequence of one or more digits
/pictures$ : ends with '/pictures'
Regex operators are case sensitive, so
\d is different from \D
and
\s is different from \S