Help to replace "." (dots) with " " (space) in a string Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Maxsteinfeld
Posts: 64
Joined: 25 Jun 2017, 02:18

Help to replace "." (dots) with " " (space) in a string

01 Apr 2019, 06:06

Hi
I need help with this:
i have a list with book-titles e.g.
Wempen,.Faithe.-.No.018.15.-.Office.-.2016.For.Seniors.For.Dummies
I want to replace all "." (dots) with " " space exept the dots between 2 digits should remain
so in my example the result should be:
Wempen, Faithe - No 018.15 - Office - 2016 For Seniors For Dummies
my first step solution:

Code: Select all

OutNameNoExt:= RegExReplace(OutNameNoExt, "[.]", " ")
generates
Wempen, Faithe - No 018 15 - Office - 2016 For Seniors For Dummies
that works so far ... but the partial result "018 15" is not wanted
what should i have to add to match, that the dots between 2 digits remain
pls help
greetz
Max
swagfag
Posts: 2922
Joined: 11 Jan 2017, 17:59

Re: Help to replace "." (dots) with " " (space) in a string

01 Apr 2019, 06:53

Code: Select all

str := "Wempen,.Faithe.-.No.018.15.-.Office.-.2016.For.Seniors.For.Dummies"
str := RegExReplace(str, "([0-9])\.([0-9])", "$1ZZZZ$2")
str := StrReplace(str, ".", " ")
str := RegExReplace(str, "ZZZZ", ".")
MsgBox % str
Odlanir
Posts: 524
Joined: 20 Oct 2016, 08:20

Re: Help to replace "." (dots) with " " (space) in a string

01 Apr 2019, 07:59

Or:

Code: Select all

str := "Wempen,.Faithe.-.No.018.15.-.Office.-.2016.For.Seniors.For.Dummies"
str := RegExReplace(str, "(\d+\.\d+)|(\.)", "$1 ")
MsgBox % str
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
swagfag
Posts: 2922
Joined: 11 Jan 2017, 17:59

Re: Help to replace "." (dots) with " " (space) in a string

01 Apr 2019, 08:15

Odlanir wrote:
01 Apr 2019, 07:59
Or:

Code: Select all

str := "Wempen,.Faithe.-.No.018.15.-.Office.-.2016.For.Seniors.For.Dummies"
str := RegExReplace(str, "(\d+\.\d+)|(\.)", "$1 ")
MsgBox % str

Code: Select all

Wempen, Faithe - No 018.15  - Office - 2016 For Seniors For Dummies
;                          ^ naaah
Odlanir
Posts: 524
Joined: 20 Oct 2016, 08:20

Re: Help to replace "." (dots) with " " (space) in a string

01 Apr 2019, 08:27

@ swagfag You're right!. It should be:

Code: Select all

str := RegExReplace(str, "(\d+\.\d+)\.?|(\.)", "$1 ")
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
User avatar
sinkfaze
Posts: 613
Joined: 01 Oct 2013, 08:01

Re: Help to replace "." (dots) with " " (space) in a string  Topic is solved

01 Apr 2019, 08:38

Code: Select all

str :=	"Wempen,.Faithe.-.No.018.15.-.Office.-.2016.For.Seniors.For.Dummies"
MsgBox %	RegExReplace(str,"\.(?=\D)|(?<=\D)\."," ")
Maxsteinfeld
Posts: 64
Joined: 25 Jun 2017, 02:18

Re: Help to replace "." (dots) with " " (space) in a string

01 Apr 2019, 08:58

@swagfag
@Odlanir
@sinkfaze
Thx for the quick response and help
all 3 solutions works perfect :-)
regards
Max

Return to “Ask For Help”

Who is online

Users browsing this forum: ac1234, eh1286, flyingDman, kczx3, teadrinker and 48 guests