-
Notifications
You must be signed in to change notification settings - Fork 998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
优化正则匹配 #246
优化正则匹配 #246
Conversation
Thanks @M2shad0w can you add some tests? |
expAlterTable = regexp.MustCompile("(?i)^ALTER\\sTABLE\\s.*?`{0,1}(.*?)`{0,1}\\.{0,1}`{0,1}([^`\\.]+?)`{0,1}\\s.*") | ||
expRenameTable = regexp.MustCompile("(?i)^RENAME\\sTABLE\\s.*?`{0,1}(.*?)`{0,1}\\.{0,1}`{0,1}([^`\\.]+?)`{0,1}\\s{1,}TO\\s.*?") | ||
expDropTable = regexp.MustCompile("(?i)^DROP\\sTABLE(\\sIF\\sEXISTS){0,1}\\s`{0,1}(.*?)`{0,1}\\.{0,1}`{0,1}([^`\\.]+?)`{0,1}(?:$|\\s)") | ||
expCreateTable = regexp.MustCompile("(?im)CREATE\\sTABLE(\\sIF\\sNOT\\sEXISTS)?\\s`{0,1}(.*?)`{0,1}\\.{0,1}`{0,1}([^`\\.]+?)`{0,1}\\s.*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you give the comment why we need to use (?im)
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INFO[0218] row data [47 42 32 65 112 112 108 105 99 97 116 105 111 110 78 97 109 101 61 80 121 67 104 97 114 109 32 50 48 49 55 46 50 46 52 32 42 47 32 65 76 84 69 82 32 84 65 66 76 69 32 99 111 109 109 117 110 105 116 121 95 99 111 109 98 105 110 101 32 67 72 65 78 71 69 32 96 50 50 50 49 51 50 96 32 102 115 100 118 102 32 73 78 84 40 49 49 41]
query data /* ApplicationName=PyCharm 2017.2.4 */ ALTER TABLE community_combine CHANGE `222132` fsdvf INT(11)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query event bin data is like /* ApplicationName=PyCharm 2017.2.4 */ ALTER TABLE community_combine CHANGE
222132fsdvf INT(11)
if not use reg 多行模式,只匹配行首就不能正确解析事件了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a test for this?
// m 多行模式:让 ^ 和 $ 匹配整个文本的开头和结尾,而非行首和行尾(默认为 false)