AHK:查找文字并全部替换

时间:2019-02-14 17:42:39

标签: autohotkey

如何将每个单词末尾的字母ve替换为字母。请查看图片:I know that this word is not correct but it is an example only to clarify 这样的代码语句:

#IfWinActive ahk_class Chrome_WidgetWin_1
F2::
    Clipboard := ""
    Send, ^+{End}
    Send, ^c
    ClipWait
    Clipboard := RegExReplace(Clipboard, "^(.*?)i(.*)", "$1o$2")
    Send, ^v
return

2 个答案:

答案 0 :(得分:1)

替换

Clipboard := RegExReplace(Clipboard, "^(.*?)i(.*)", "$1o$2")

使用

Clipboard := RegExReplace(Clipboard, "ve\b", "on")

\ b使其仅与单词末尾的“ ve”匹配,例如,它将“ vetvetve”更改为“ vetveton” 请注意,RegExReplace区分大小写(不会更改“ VETVETVE”),请使用i)选项使其不区分大小写:

Clipboard := RegExReplace(Clipboard, "i)ve\b", "on")

答案 1 :(得分:0)

您不需要此正则表达式。您可以改为使用简单的字符串替换

#IfWinActive ahk_class Chrome_WidgetWin_1
F2::
    Clipboard := ""
    Send, ^+{End}
    Send, ^c
    ClipWait
    Clipboard := StrReplace(Clipboard, "ve", "on")
    Send, ^v
return