1
votes

How do I replace the letters ve at the end of each word with the letters on. Please see the picture:I know that this word is not correct but it is an example only to clarify Such a code sentence:

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

2

2 Answers

1
votes

Replace the

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

with

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

The \b makes it match only the "ve" at the end of words, for example, it will change "vetvetve" to "vetveton" Note that RegExReplace is case sensitive (it will not change "VETVETVE"), to make it case-insensitive use the i) option:

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

You don't need a regex for this one. You can instead use a simple string replace

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