testregexcompiler.py

来自「Python Development Environment (Python I」· Python 代码 · 共 32 行

PY
32
字号
import re
# These statements dont require a AST regular expression node
m = re.search('(?<=-)\w+', 'spam-egg')
print m.group(0)
re.compile("a").match("ba", 1)
re.split('(\W+)', 'Words, words, words.')
re.sub(r'def\s+([a-zA-Z_][a-zA-Z_0-9]*)\s*\(\s*\):', r'static PyObject*\npy_\1(void)\n{', 'def myfunc():')
pattern = '^M?M?M?$'
re.search(pattern, 'M')
def firstMatch(s, regexList):
    for match in (regex.search(s) for regex in regexList):
        if match:
            return match
        # some comment after firstMatch
##r
import re
# These statements dont require a AST regular expression node
m = re.search('(?<=-)\w+', 'spam-egg')
print m.group(0)
re.compile("a").match("ba", 1)
re.split('(\W+)', 'Words, words, words.')
re.sub(r'def\s+([a-zA-Z_][a-zA-Z_0-9]*)\s*\(\s*\):', r'static PyObject*\npy_\1(void)\n{', 'def myfunc():')
pattern = '^M?M?M?$'
re.search(pattern, 'M')
def firstMatch(s, regexList):
    for match in (regex.search(s) for regex in regexList):
        if match:
            return match
        
    

# some comment after firstMatch   

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?