add freq
[dumbwifi.git] / regex.py
blob6590f0e7c845c0584eee34bc6d5c9bbf71ad6e57
1 # Author: Martin Matusiak <numerodix@gmail.com>
2 # Licensed under the GNU Public License, version 3.
4 import re
7 # String matching
9 def matches(r, s):
10 m = re.compile(r).search(s)
11 if m: return True
13 def find1(r, s):
14 if not s: return ""
15 m = re.compile(r).search(s)
16 if m and m.groups() and m.groups()[0]:
17 return m.groups()[0]
19 def find(r, s):
20 m = re.compile(r).search(s)
21 if m: return m
22 #return m.groups()
24 def findall(r, s):
25 m = re.compile(r).findall(s)
26 if m: return m
28 def replaceall(old, new, s):
29 return re.sub(old, new, s)