找回密码
 加入
搜索
查看: 1152|回复: 2

[AU3基础] 已解决 如何用正则批量替换IF...Then... 中Then之前的内容?

[复制链接]
发表于 2012-3-26 22:29:32 | 显示全部楼层 |阅读模式
本帖最后由 Qokelate 于 2012-3-27 21:36 编辑
If Not IsDeclared("ERROR_NO_MORE_ITEMS") Then Global Const $ERROR_NO_MORE_ITEMS = 259
把这种句型直接删除Then前的内容,比如上例替换后是Global Const $ERROR_NO_MORE_ITEMS = 259

答案见2楼和4楼
发表于 2012-3-26 22:46:19 | 显示全部楼层
正则我还很菜 只知道能达到效果 不知是否标准

$str = 'If Not IsDeclared("ERROR_NO_MORE_ITEMS") Then Global Const $ERROR_NO_MORE_ITEMS = 259'
MsgBox (0,0,StringRegExpReplace($str,'If.+Then (.+)','$1'))

评分

参与人数 1金钱 +10 收起 理由
Qokelate + 10 厉害!学习!

查看全部评分

发表于 2012-3-27 03:10:06 | 显示全部楼层
Local $Str = _
                'If Not IsDeclared("ERROR_NO_MORE_ITEMS") Then Global Const $ERROR_NO_MORE_ITEMS = 259' & @CRLF & _
                ' wwwwwwwwwwwwwww' & @CRLF & _
                'wwww' & @CRLF & _
                ' If Not IsDeclared("ERROR_NO_MORE_ITEMS") Then Global Const $ERROR_NO_MORE_ITEMS = 259' & @CRLF & _
                '        If Not IsDeclared("ERROR_NO_MORE_ITEMS") Then Global Const $ERROR_NO_MORE_ITEMS = 259' & @CRLF & _
                ' deeeeee' & @CRLF & _
                'If Not IsDeclared("ERROR_NO_MORE_ITEMS") Then Global Const $ERROR_NO_MORE_ITEMS = 259'
MsgBox(0, '原字符串', $Str)
Local $Test = StringRegExpReplace($str, '(?mi)^\s*if.+Then\s*(.+)', '\1')
MsgBox(0, '替换结果', $Test)

评分

参与人数 2金钱 +30 收起 理由
Qokelate + 20 厉害!
zch11230 + 10 这才标准

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-30 17:32 , Processed in 0.081611 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表