bleh = 987654
I would like to create a variable from that 9 8 7 6 5 4
what would be the right way? regex? and if so, what is the regex code?
thank you
Adding one space after each number
Re: Adding one space after each number
Code: Select all
bleh = 987654
msgbox, % RegExReplace(bleh, "(\d)", "$1 ")
Re: Adding one space after each number
works really well, what do i add so it does it regardless if its a digit or letter? I tried RegExReplace(bleh, "(\d\w)", "$1 ") but it didnt workUser wrote:Code: Select all
bleh = 987654 msgbox, % RegExReplace(bleh, "(\d)", "$1 ")
thanks
Re: Adding one space after each number
Try this:Cheers!
Code: Select all
bleh = 98abc7654
msgbox, % RegExReplace(bleh, "[a-zA-Z0-9]", "$0 ")
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Re: Adding one space after each number
I have this, is there a downside to it? "(\w)", "$1 ")iPhilip wrote:Try this:Cheers!Code: Select all
bleh = 98abc7654 msgbox, % RegExReplace(bleh, "[a-zA-Z0-9]", "$0 ")
Re: Adding one space after each number
you can use the code below too, though I think iPhilip approach is more suitable!Baba Katchka wrote:I have this, is there a downside to it? "(\w)", "$1 ")
The code below adds one space after any character within the original text, including space character itself!
Code: Select all
bleh := "ABC D `r`n`r`n[(* % `r`n`r`n123 4"
blehSpace := RegExReplace(bleh, ".", "$0 ")
msgbox, % bleh "`n______________`n`n" blehSpace
Re: Adding one space after each number
That would work as well but the \w syntax matches alphanumeric or underscore, which is different than your original requirement:Baba Katchka wrote:I have this, is there a downside to it? "(\w)", "$1 ")
Also, note that subpatterns are not necessary in this solution. As shown above, the "\w", "$0 " syntax works, where $0 is the substring that matched the entire pattern.Baba Katchka wrote:... it does it regardless if its a digit or letter
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Who is online
Users browsing this forum: CuriousDad, Google [Bot], rc76 and 230 guests