StringReplace "," instead "/" Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
HiSoKa
Posts: 480
Joined: 27 Jan 2020, 15:43

StringReplace "," instead "/"

27 Sep 2021, 11:39

Hello,
I have string i want to replace slash(/) with comma(,)
Please take a look at my attempts:
This work well with dash(-):

Code: Select all

Clipboard = Android / Windows / Xbox One

StringReplace, NewName, % Clipboard, /, -, All
MsgBox, %NewName%
Return

When i write comma(,) between quotes instead dash(-) it does not work (I thought I should to put quotes because there is a parameter):

Code: Select all

Clipboard = Android / Windows / Xbox One

StringReplace, NewName, % Clipboard, /, ",", All
MsgBox, %NewName%
Return

The code below works as expected but as you can see I have to set a variable containing the comma sign,
Is there a better way to do this thing?

Code: Select all

Clipboard = Android / Windows / Xbox One
Comma := ","

StringReplace, NewName, % Clipboard, /, %Comma%, All
MsgBox, %NewName%
Return


Esc::ExitApp
User avatar
mikeyww
Posts: 27082
Joined: 09 Sep 2014, 18:38

Re: StringReplace "," instead "/"  Topic is solved

27 Sep 2021, 11:43

Code: Select all

new := StrReplace(Clipboard, "/", ",")
Escape sequences
Last edited by mikeyww on 27 Sep 2021, 11:46, edited 1 time in total.
braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

Re: StringReplace "," instead "/"

27 Sep 2021, 11:45

First:
Stringreplace is deprecated:
AHK documentation wrote:This command is not recommended for use in new scripts. Use the StrReplace function instead.
Second:
Stringreplace uses the legacy command format, so a comma must be escaped: `,
User avatar
HiSoKa
Posts: 480
Joined: 27 Jan 2020, 15:43

Re: StringReplace "," instead "/"

27 Sep 2021, 12:02

braunbaer wrote:
27 Sep 2021, 11:45
First:
Stringreplace is deprecated:
AHK documentation wrote:This command is not recommended for use in new scripts. Use the StrReplace function instead.
Second:
Stringreplace uses the legacy command format, so a comma must be escaped: `,
Thank you for the clarification

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder and 267 guests