regexreplace help

Get help with using AutoHotkey and its commands and hotkeys
User avatar
noname
Posts: 510
Joined: 19 Nov 2013, 09:15

regexreplace help

07 Sep 2016, 03:10

Code: Select all

data=
(
F:\korean drama\yu na\Yoona's Street Episode 50.mp4
F:\korean drama\yu na\Yoona's Street Episode 505.mp4
F:\korean drama\yu na\Yoona's Street Episode 5021.mp4
F:\korean drama\yu na\Yoona's Street Episode 50464.mp4
)

index:=["a","b","c","d"]
Loop, parse,data,`n
list .= regexreplace(A_LoopField,"(\d\d)\d?\d?\d?","$1" index[A_Index]) "`n"

msgbox %list%
This works but it is possible to simplify the "\d?\d?\d?" part?
soundcloud.com/user-32706894
drawback
Posts: 34
Joined: 11 Aug 2016, 11:31

Re: regexreplace help

07 Sep 2016, 04:50

Code: Select all

list .= regexreplace(A_LoopField,"(\d\d)\d{1,3}","$1" index[A_Index]) "`n"
User avatar
noname
Posts: 510
Joined: 19 Nov 2013, 09:15

Re: regexreplace help

07 Sep 2016, 05:21

Thanks but the first one misses the "a" index .........
---------------------------
Episode.ahk
---------------------------
F:\korean drama\yu na\Yoona's Street Episode 50.mp4
F:\korean drama\yu na\Yoona's Street Episode 50b.mp4
F:\korean drama\yu na\Yoona's Street Episode 50c.mp4
F:\korean drama\yu na\Yoona's Street Episode 50d.mp4

---------------------------
OK
---------------------------
soundcloud.com/user-32706894
Helgef
Posts: 4481
Joined: 17 Jul 2016, 01:02
Contact:

Re: regexreplace help

07 Sep 2016, 05:36

drawback wrote:

Code: Select all

list .= regexreplace(A_LoopField,"(\d\d)\d{1,3}","$1" index[A_Index]) "`n" ; not working
list .= regexreplace(A_LoopField,"(\d\d)\d{0,3}","$1" index[A_Index]) "`n" ; working
Alternative, working for more digits between the two first and the .mp4:

Code: Select all

list .= regexreplace(A_LoopField,"(\d\d)(\d+|)","$1" index[A_Index]) "`n"
list .= regexreplace(A_LoopField,"(\d\d)\d{0,}","$1" index[A_Index]) "`n" 
What is is simpler? I don't know.
User avatar
noname
Posts: 510
Joined: 19 Nov 2013, 09:15

Re: regexreplace help

07 Sep 2016, 05:48

Thanks Helgef i will use the d{0,3} , i tried itbefore but unfortunately used letter "o" instead of 0 :)

(\d+|) is a nice one !
soundcloud.com/user-32706894
Helgef
Posts: 4481
Joined: 17 Jul 2016, 01:02
Contact:

Re: regexreplace help

07 Sep 2016, 05:50

noname wrote:Thanks Helgef i will use the d{0,3} , i tried itbefore but unfortunately used letter "o" instead of 0 :)

(\d+|) is a nice one !
Np, I hate when that happens o_0
User avatar
AlphaBravo
Posts: 513
Joined: 29 Sep 2013, 22:59

Re: regexreplace help

07 Sep 2016, 08:36

Helgef wrote: Alternative, working for more digits between the two first and the .mp4:

Code: Select all

list .= regexreplace(A_LoopField,"(\d\d)(\d+|)","$1" index[A_Index]) "`n"
list .= regexreplace(A_LoopField,"(\d\d)\d{0,}","$1" index[A_Index]) "`n" 
What is is simpler? I don't know.
or maybe

Code: Select all

list .= regexreplace(A_LoopField,"(\d\d)\d*","$1" index[A_Index]) "`n"
Helgef
Posts: 4481
Joined: 17 Jul 2016, 01:02
Contact:

Re: regexreplace help

07 Sep 2016, 09:26

AlphaBravo wrote: or maybe

Code: Select all

list .= regexreplace(A_LoopField,"(\d\d)\d*","$1" index[A_Index]) "`n"
Even better!

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], JoeWinograd, manehscripts, nu10e8368NrrfXGQKvwn, ToJaRedi and 75 guests