Remove special characters from variable Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DarkSider
Posts: 50
Joined: 29 May 2019, 11:06

Remove special characters from variable

27 Nov 2021, 07:29

Hi,

I'm trying to load some info into a variable, but the info contains special characters like - / \. I'm not sure how to remove all of those.
I'm testing with this script, to remove just a - which appears in my computer name:

Code: Select all

info := StrReplace(%computername%,-, %A_Space%)
msgbox, %info%
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Remove special characters from variable  Topic is solved

27 Nov 2021, 07:35

Functions use expressions rather than literal strings.

Code: Select all

MsgBox % name := StrReplace(A_ComputerName, "-", A_Space)

Code: Select all

MsgBox % name := RegExReplace(A_ComputerName, "i)[^a-z0-9 ]")

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: RandomBoy, Theda and 269 guests