Hello AHK professionals !
I am new to AHK and I am trying to replace a ";" with a "/" once I copied a text in the clipboard.
I tried the following without success and wonder if someone can point me into the right direction.
StringReplace, clipboard, clipboard,";" , "/", All
StringReplace, clipboard, clipboard,`;,/,All
I appreciate your help !
TZ
replace a ";" with a "/" once I copied a text in the clipboard Topic is solved
-
- Posts: 302
- Joined: 05 Feb 2017, 00:03
Re: replace a ";" with a "/" once I copied a text in the clipboard
Try:
Code: Select all
removed, check comment below
Last edited by Nightwolf85 on 16 Jun 2017, 10:36, edited 1 time in total.
Re: replace a ";" with a "/" once I copied a text in the clipboard
do not use regex for this insanely simple replacement. it's overkill and will only teach people bad practices.Nightwolf85 wrote:Try:Code: Select all
#Persistent OnClipboardChange: IF (A_EventInfo = 1) clipboard := RegExReplace(clipboard, ";","/") Return
use stringreplace or strreplace()
regex is much slower (noticable in a large loop) and meant for dynamic, changing, non-static stuff, like matching absd-12125 AND ajsf-1275615512a.
and then you'll also need to escape many things. like if he, or anyone who learns to use regex for simple things, wants to replace [ with (, it won't work. it'll need to be \[. which is not obvious.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
*poke*
Is it December 21, 2012 yet?
-
- Posts: 302
- Joined: 05 Feb 2017, 00:03
Re: replace a ";" with a "/" once I copied a text in the clipboard Topic is solved
Sorry, Habit... and one I seem to not be able to get over.tidbit wrote:do not use regex for this insanely simple replacement. it's overkill and will only teach people bad practices.
Code: Select all
#Persistent
OnClipboardChange:
IF (A_EventInfo = 1)
clipboard := StrReplace(clipboard, ";","/")
Return