Project

General

Profile

« Previous | Next » 

Revision 12746

bin/repl: text mode: exclude prefixes that should not cause replacement, to avoid doubling leading *

View differences:

trunk/bin/repl
15 15
import strings
16 16

  
17 17
quote_re = '[\'"`]'
18
excluded_prefix_re = (
19
	'(?<!\*)' # don't double leading *
20
	)
18 21

  
19 22
def unescape_html(str_): return HTMLParser.HTMLParser().unescape(str_)
20 23

  
......
49 52
                q = quote_re
50 53
                in_ = '(?<='+q+')'+in_str_re+'(?='+q+')' # require quotes
51 54
                if is_word: # also match with quotes optional
52
                    in_word_re = r'\b'+in_str_re+r'(?=\b|_)' # also w/ suffix
55
                    in_word_re = excluded_prefix_re+r'\b'+in_str_re+r'(?=\b|_)'
56
                        # (?=\b|_): also match w/ _* suffix
53 57
                    in_ = '(?:'+in_+'|'+in_word_re+')'
54 58
            repls.append((r'(?m)'+in_, out))
55 59
    stream.close()

Also available in: Unified diff