Revision 6713
Added by Aaron Marcuse-Kubitza about 12 years ago
bin/repl | ||
---|---|---|
36 | 36 |
in_, out = row[:2] |
37 | 37 |
if in_ != '': |
38 | 38 |
if text or re.match(r'^\w+$', in_): # match word |
39 |
in_ = r'(?:^|(?<=[\s,"]))(:?)'+re.escape(in_)+r'(?![^\W_.-])' |
|
40 |
repls.append((r'(?m)'+in_, r'\1'+out)) |
|
39 |
in_ = (r'(?:^|(?<=[\s,"])|^:|(?<=[\s,"]):)'+re.escape(in_) |
|
40 |
+r'(?![^\W_.-])') |
|
41 |
repls.append((r'(?m)'+in_, out)) |
|
41 | 42 |
stream.close() |
42 | 43 |
def repl_all(str_): |
43 | 44 |
for repl, with_ in repls: str_ = re.sub(repl, with_, str_) |
Also available in: Unified diff
repl: :-prefixing of words to form vars: Fixed bug where : must be matched as a lookbehind assertion, not a capturing group, because the provided regexp itself or its replacement may reference capturing groups, which it expects to be numbered starting with 1