Project

General

Profile

« Previous | Next » 

Revision 6702

repl: text mode: Also match "vars" with the term prefixed by ":". Consider .- to be word characters. Only match a word when preceeded by whitespace or CSV field start characters.

View differences:

bin/repl
35 35
    for row in reader:
36 36
        in_, out = row[:2]
37 37
        if in_ != '':
38
            if text or re.match(r'^\w+$', in_):
39
                in_ = r'(?<![^\W_])'+re.escape(in_)+r'(?![^\W_])' # match word
40
            repls.append((r'(?m)'+in_, out))
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))
41 41
    stream.close()
42 42
    def repl_all(str_):
43 43
        for repl, with_ in repls: str_ = re.sub(repl, with_, str_)

Also available in: Unified diff