root/trunk/lib/regexp.py @ 14222
1 |
# Regular expression processing
|
---|---|
2 |
|
3 |
import re |
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 |
|
14 |
def sub_nested(re_, repl, str_): |
15 |
return sub_recursive(lambda s: re.subn(re_, repl, s), str_) |