Skip to content

Commit

Permalink
r"" is best regex string
Browse files Browse the repository at this point in the history
  • Loading branch information
yrsegal committed Sep 1, 2015
1 parent 232942b commit 2e48d4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions oneCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CmdVariable:
def __init__(self, name, replacewith):
self.name = name
self.replacewith = replacewith
self.regex = re.compile("\\$"+name.lower()+"\\b", re.IGNORECASE)
self.regex = re.compile(r"\$"+name.lower()+r"\b", re.IGNORECASE)
def sub(self, string):
return self.regex.sub(self.replacewith, string)

Expand Down Expand Up @@ -115,15 +115,15 @@ def gen_stack(init_commands, clock_commands, mode, loud=False):

return final_command

tag_regex = re.compile(r"^[ \t]*(INIT:|COND:|REPEAT:)", re.IGNORECASE)
init_tag_regex = re.compile(r"^[ \t]*((INIT:|COND:|REPEAT:)[ \t]*)*INIT:", re.IGNORECASE)
cond_tag_regex = re.compile(r"^[ \t]*((INIT:|COND:|REPEAT:)[ \t]*)*COND:", re.IGNORECASE)
tag_regex = re.compile(r"^[ \t]*(INIT:|COND:|REPEAT:)", re.IGNORECASE)
init_tag_regex = re.compile(r"^[ \t]*((INIT:|COND:|REPEAT:)[ \t]*)*INIT:", re.IGNORECASE)
cond_tag_regex = re.compile(r"^[ \t]*((INIT:|COND:|REPEAT:)[ \t]*)*COND:", re.IGNORECASE)
repeat_tag_regex = re.compile(r"^[ \t]*((INIT:|COND:|REPEAT:)[ \t]*)*REPEAT:", re.IGNORECASE)
init_regex = re.compile(r"INIT:", re.IGNORECASE)
cond_regex = re.compile(r"COND:", re.IGNORECASE)
repeat_regex = re.compile(r"REPEAT:", re.IGNORECASE)
define_regex = re.compile(r"^[ \t]*DEFINE:", re.IGNORECASE)
comment_regex = re.compile(r"^[ \t]*#", re.IGNORECASE)
init_regex = re.compile(r"INIT:", re.IGNORECASE)
cond_regex = re.compile(r"COND:", re.IGNORECASE)
repeat_regex = re.compile(r"REPEAT:", re.IGNORECASE)
define_regex = re.compile(r"^[ \t]*DEFINE:", re.IGNORECASE)
comment_regex = re.compile(r"^[ \t]*#", re.IGNORECASE)

def parse_commands(commands):
init_commands = []
Expand Down
4 changes: 2 additions & 2 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def format(string, **kwargs):
Format strings with **kwargs.
"""
for arg in kwargs:
regex = re.compile("\\{" + arg + "\\}", re.IGNORECASE)
regex = re.compile(r"\{" + arg + r"\}", re.IGNORECASE)
string = regex.sub(str(kwargs[arg]), string)
for color in bcolors.COLORS:
regex = re.compile("\\{" + color + "\\}", re.IGNORECASE)
regex = re.compile(r"\{" + color + r"\}", re.IGNORECASE)
string = regex.sub(str(bcolors.COLORS[color]), string)
return string

Expand Down

0 comments on commit 2e48d4e

Please sign in to comment.