mIRC Homepage
Posted By: nelgin Removing leading numbers. - 31/05/06 07:54 PM
It's been so long since I did much scripting, this has probably been done before smile

I have a list of mp3 files in a @window.

Some of them, however, have leading track numbers such as

01 - Genesis - Invisible Touch
02 - Genesis - Tonight, Tonight, Tonight

And some of them don't

REM - The Sidewinder Sleeps Tonite

Has anyone written a routeine to get rid only leading numbers and the dash and space?

TIA.
Mr Lazy wink
Posted By: MikeChat Re: Removing leading numbers. - 31/05/06 08:07 PM
try something like this
Code:
alias test {
  var %songname = 02 - Genesis - Tonight, Tonight, Tonight
  if ($left(%songname,1) isnum 0-9) { var %songname = $gettok(%songname,2-,45) }
    echo -s %songname
}
Posted By: schaefer31 Re: Removing leading numbers. - 01/06/06 04:33 AM
What if the band name starts with a number? wink

This matches and removes (if it is present) a song number consisting of 1 or 2 numbers followed by a space and a dash at the start of the string. Otherwise the string is returned as is.

Code:
alias nosongnum return $regsubex($1-,/^(?:\d|\d\d)\s-/,)


//echo -a $nosongnum(11th Song - One For Reality) --> 11th Song - One For Reality
//echo -a $nosongnum(1 - 11th Song - One For Reality) --> 11th Song - One For Reality
//echo -a $nosongnum(10 - 11th Song - One For Reality) --> 11th Song - One For Reality
//echo -a $nosongnum(01 - 11th Song - One For Reality) --> 11th Song - One For Reality

mIRC 6.17 is required for this to work since regsubex does not exist in previous versions.
Posted By: hixxy Re: Removing leading numbers. - 01/06/06 12:07 PM
That expression could be improved slightly.

/^(?:\d|\d\d)\s-/

(?:\d|\d\d) can become \d\d? - the "?" means that the second digit is optional, so it can be there but doesn't have to be.

\s will match any whitespace character ($cr, $lf, a tab, etc) so it's better to just use a space.

/^\d\d? -/
© mIRC Discussion Forums