我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用re._compile()。
def test_pickling(self): import pickle self.pickle_test(pickle) import cPickle self.pickle_test(cPickle) # old pickles expect the _compile() reconstructor in sre module import_module("sre", deprecated=True) from sre import _compile # current pickle expects the _compile() reconstructor in re module from re import _compile
def install(): """Install the hooks for measuring import and regex compile time.""" __builtins__['__import__'] = timed_import re._compile = timed_compile
def uninstall(): """Remove the import and regex compile timing hooks.""" __builtins__['__import__'] = _real_import re._compile = _real_compile
def test_pickling(self): import pickle oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)', re.UNICODE) for proto in range(pickle.HIGHEST_PROTOCOL + 1): pickled = pickle.dumps(oldpat, proto) newpat = pickle.loads(pickled) self.assertEqual(newpat, oldpat) # current pickle expects the _compile() reconstructor in re module from re import _compile