Adding special characters to Python regex engine -
i have project searching bytecode instructions , expand allow use of regular expressions matching patterns.
the gist of want have custom character classes/sets can have such istore match of following instructions:
istore istore_0 istore_1 istore_2 istore_3
and similar iload ... iload_n etc.
istore , iload similar metacharacters \s stand multiple characters.
basically looking jumping off point can find way implement own metacharacters.
you don't need modify regex engine (which quite difficult)
you need helper function convert flavour of regex python's in same way use re.escape
def my_re_escape(regex): regex = re.escape(regex) regex = regex.replace('foo', 'bar') # etc return regex
Comments
Post a Comment