replace a ";" with a "/" once I copied a text in the clipboard Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tituszim
Posts: 1
Joined: 16 Jun 2017, 07:48

replace a ";" with a "/" once I copied a text in the clipboard

16 Jun 2017, 07:55

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
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: replace a ";" with a "/" once I copied a text in the clipboard

16 Jun 2017, 08:44

Try:

Code: Select all

removed, check comment below
Last edited by Nightwolf85 on 16 Jun 2017, 10:36, edited 1 time in total.
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: replace a ";" with a "/" once I copied a text in the clipboard

16 Jun 2017, 10:32

Nightwolf85 wrote:Try:

Code: Select all

#Persistent

OnClipboardChange:
	IF (A_EventInfo = 1)
		clipboard := RegExReplace(clipboard, ";","/")
Return
do not use regex for this insanely simple replacement. it's overkill and will only teach people bad practices.
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?
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: replace a ";" with a "/" once I copied a text in the clipboard  Topic is solved

16 Jun 2017, 10:35

tidbit wrote:do not use regex for this insanely simple replacement. it's overkill and will only teach people bad practices.
Sorry, Habit... and one I seem to not be able to get over.

Code: Select all

#Persistent

OnClipboardChange:
	IF (A_EventInfo = 1)
		clipboard := StrReplace(clipboard, ";","/")
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, GollyJer, Lamron750 and 260 guests