Revision 5352
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/regexp.py | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import re |
4 | 4 |
|
5 |
def sub_recursive(sub_func, str_): |
|
6 |
''' |
|
7 |
@param sub_func(str_):str_, n |
|
8 |
''' |
|
9 |
while True: |
|
10 |
str_, n = sub_func(str_) |
|
11 |
if n == 0: break |
|
12 |
return str_ |
|
13 |
|
|
5 | 14 |
def sub_nested(re_, repl, str_): |
6 | 15 |
while True: |
7 | 16 |
str_, n = re.subn(re_, repl, str_) |
Also available in: Unified diff
regexp.py: Added sub_recursive()