StringReplace

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Swagcheck
Posts: 10
Joined: 13 Jan 2020, 08:51

StringReplace

27 Mar 2020, 21:41

I need to remove from a variable two numbers followed by a space from 01 to 25. Could someone demonstrate how to do this instead of:

StringReplace, stitle, stitle, 01%A_SPACE%,,All
StringReplace, stitle, stitle, 02%A_SPACE%,,All
StringReplace, stitle, stitle, 03%A_SPACE%,,All
...
sofista
Posts: 654
Joined: 24 Feb 2020, 13:59
Location: Buenos Aires

Re: StringReplace

27 Mar 2020, 22:21

Hi. Try this:

Code: Select all

stitle := "NiceTitle08 "
stitle := RegExReplace(stitle, "0[1-9]|1[0-9]|2[0-5] ", "")
MsgBox, % stitle
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: StringReplace

28 Mar 2020, 00:00

Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
teadrinker
Posts: 4412
Joined: 29 Mar 2015, 09:41
Contact:

Re: StringReplace

28 Mar 2020, 01:41

Code: Select all

stitle := "text08 text26 text18 text"
MsgBox, % RegExReplace(stitle, "(0[1-9]|1\d|2[0-5]) ")
User avatar
emmanuel d
Posts: 90
Joined: 17 Nov 2013, 04:45

Re: StringReplace

30 Mar 2020, 14:50

If you dont like regex: (untested code):

Code: Select all

Loop,25
	StringReplace, stitle, stitle,% SubStr(00 A_Index,-1) A_SPACE,,All
Substring is there so we always have 2 digits

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 295 guests