SubStr InStr problem

Get help with using AutoHotkey and its commands and hotkeys
zcooler
Posts: 455
Joined: 11 Jan 2014, 04:59

SubStr InStr problem

30 Apr 2017, 05:36

Hmm...I should be abled to solve this one, but Im stuck and out of ideas. Its quite hard when the string Im after doesnt have anything to the right besides a newline char. I get odd results when Loop parsing it using the `n. Im after all channel names after "Favourites - "

Code: Select all

FavL :=
(
"
#EXTM3U

#EXTINF:-1,Favourites - SVT1 HD

http://127.0.0.1:7522/upnp/channelstream/3713217920236979536%7CSVT1%20HD.ts

#EXTINF:-1,Favourites - SVT2 HD

http://127.0.0.1:7522/upnp/channelstream/3713217920302516536%7CSVT2%20HD.ts

#EXTINF:-1,Favourites - TV3

http://127.0.0.1:7522/upnp/channelstream/3713222661988420536%7CTV3.ts

#EXTINF:-1,Favourites - TV4

http://127.0.0.1:7522/upnp/channelstream/3713222283902851038%7CTV4.ts

#EXTINF:-1,Favourites - Kanal 5

http://127.0.0.1:7522/upnp/channelstream/3713222662021189036%7CKanal%205.ts

#EXTINF:-1,Favourites - TV6

http://127.0.0.1:7522/upnp/channelstream/3713222283904812078%7CTV6.ts

#EXTINF:-1,Favourites - Sjuan

http://127.0.0.1:7522/upnp/channelstream/3713222284306553888%7CSjuan.ts

#EXTINF:-1,Favourites - TV8

http://127.0.0.1:7522/upnp/channelstream/3713222661863244866%7CTV8.ts

#EXTINF:-1,Favourites - Kanal 9

http://127.0.0.1:7522/upnp/channelstream/3713222666141827912%7CKanal%209.ts

#EXTINF:-1,Favourites - TV10

http://127.0.0.1:7522/upnp/channelstream/3713222666164765862%7CTV10.ts

#EXTINF:-1,Favourites - TV12

http://127.0.0.1:7522/upnp/channelstream/3713222670430896878%7CTV12.ts

#EXTINF:-1,Favourites - Discovery Channel

http://127.0.0.1:7522/upnp/channelstream/3713222666147726242%7CDiscovery%20Channel.ts

#EXTINF:-1,Favourites - Barnkanalen/SVT24 (swe)

http://127.0.0.1:7522/upnp/channelstream/3713222279596344166%7CBarnkanalen%2FSVT24%20%28swe%29.ts

#EXTINF:-1,Favourites - Kunskapskanalen (swe)

http://127.0.0.1:7522/upnp/channelstream/3713222279620592856%7CKunskapskanalen%20%28swe%29.ts
"
)

Loop, Parse, FavL, `n
{
  ;msgbox % A_LoopField
  Favourites .= (A_Index > 1 ? "`n" : "") SubStr(A_LoopField, InStr(A_LoopField, "Favourites - ") + 13, InStr(A_LoopField, "`n") - InStr(A_LoopField, "Favourites - ") - 13)
  ;RegExMatch(A_LoopField, "Favourites - \K.+?`n", Favourites)
}
Msgbox % Favourites
just me
Posts: 7294
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: SubStr InStr problem

30 Apr 2017, 05:47

Code: Select all

Favourites := ""
Loop, Parse, FavL, `n, `r
{
   If (P := InStr(A_LoopField, "Favourites -"))
      Favourites .= (Favourites ? "`n" : "") . Trim(SubStr(A_LoopField, P + 13))
}
?
zcooler
Posts: 455
Joined: 11 Jan 2014, 04:59

Re: SubStr InStr problem

30 Apr 2017, 05:59

Hey, just me,

That is precisely what I was after :)
Many Thanks
zcooler :wave:

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Dante, DavidP, Google [Bot], Lem2001, mikeyww, nestea2k and 49 guests