Skip to content
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

Closed
wants to merge 1 commit into from
Closed

优化正则匹配 #246

wants to merge 1 commit into from

Conversation

M2shad0w
Copy link

@M2shad0w M2shad0w commented Apr 3, 2018

// m 多行模式:让 ^ 和 $ 匹配整个文本的开头和结尾,而非行首和行尾(默认为 false)

//  m  多行模式:让 ^ 和 $ 匹配整个文本的开头和结尾,而非行首和行尾(默认为 false)
@siddontang
Copy link
Collaborator

siddontang commented Apr 3, 2018

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.*")
Copy link
Collaborator

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?

Copy link
Author

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) 

Copy link
Author

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 多行模式,只匹配行首就不能正确解析事件了

Copy link
Collaborator

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?

@IANTHEREAL
Copy link
Collaborator

#382 is the better way, I think we should close this pr, still thanks @M2shad0w

@IANTHEREAL IANTHEREAL closed this Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants