Last active
February 2, 2021 07:35
-
-
Save ourdaidai/2d80e6484f4482d338c715889b6fa7c3 to your computer and use it in GitHub Desktop.
[正则表达式] #reg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 匹配表注释,只保留中文英文,忽略数据字典 | |
| ^[\u4e00-\u9fa5_a-zA-Z0-9]+ | |
| 匹配XX_AA_XX中的 'AA' | |
| (?<=_).*?(?=_) | |
| # 匹配 'CREATE TABLE TEST22 SELECT uid from test1' 中的 'TEST22' | |
| def extract_table_name(sql): | |
| sql = re.sub(r'\s+', ' ', sql) | |
| p_name = re.compile(r'(?<=(CREATE TABLE\s))\S+') | |
| res = p_name.search(sql) | |
| return res.group() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment