mIRC Homepage
Posted By: Sjoepele Stripping text - 11/02/15 11:38 PM
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
Posted By: Sakana Re: Stripping text - 12/02/15 12:01 AM
Code:
alias test {
  var %song = “Lay Your Love Down - Single Version” ― Wolf Gang
  if $regex(%song,/“(.*?)”/) {
    echo -a $regml(1)
  }
}


wink
Posted By: Sjoepele Re: Stripping text - 12/02/15 12:35 AM
Ah, the magical realm of regex smile

thanks a bunch! worked perfectly ^_^
© mIRC Discussion Forums