mIRC Home    About    Download    Register    News    Help

Print Thread
#251218 11/02/15 11:38 PM
Joined: Mar 2014
Posts: 42
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2014
Posts: 42
Hi,

lets say we have a file with a single line. that single line contains info about the song thats currently playing in a media player with the format "song" - artist.

for example
Code:
“Lay Your Love Down - Single Version” ― Wolf Gang


Lets say i want to extract ONLY the song name (so the part inside the quotations) i'm curious what the best way would be to do so.

myself i've tried to tackle this with $pos to check the position of the second quotation mark, only to find out that special characters (or their $chr versions) aren't supported by $pos
Code:
var %readsong $read(nowplaying.txt)
  var %poschr34 $pos(%readsong, $chr(34))
  set %song $mid(%readsong,2,$calc(%poschr34 - 1))


Also earlier when i used $pos in an earlier question i was advised to not use it.

Its kind of frustrating that this looks so easy, yet i have no answer to it, so help, as always, would be appreciated smile

Sjoepele #251220 12/02/15 12:01 AM
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Code:
alias test {
  var %song = “Lay Your Love Down - Single Version” ― Wolf Gang
  if $regex(%song,/“(.*?)”/) {
    echo -a $regml(1)
  }
}


wink

Last edited by Sakana; 12/02/15 12:01 AM.
Sakana #251221 12/02/15 12:35 AM
Joined: Mar 2014
Posts: 42
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2014
Posts: 42
Ah, the magical realm of regex smile

thanks a bunch! worked perfectly ^_^


Link Copied to Clipboard