Re: Need help with this
- Posted by Alex Chamberlain <alex.chamberlain at tiscali.co.uk> Dec 18, 2005
- 539 views
This is my example program - the function you want is in it!
constant NUMBERS = "0123456789" constant WHITE_SPACE = " \n\r\t" -- This is the function you want! Some credit Please! function remove_numbers(sequence text) integer tmp_pos, j sequence tmp_ret tmp_pos = find('-', text) if tmp_pos then tmp_ret = {} j = 0 for i = 1 to tmp_pos do if find(text[i], NUMBERS) or find(text[i], WHITE_SPACE) then j = i else if j = tmp_pos-1 then tmp_ret = text[tmp_pos+1..length(text)] exit else tmp_ret = text exit end if end if end for while find(tmp_ret[1], WHITE_SPACE) do tmp_ret = tmp_ret[2..length(tmp_ret)] end while else tmp_ret = text end if return tmp_ret end function sequence txt, txt_ret txt = "01-MyText" txt_ret = remove_numbers(txt) puts(1, txt_ret & '\n') txt = "01 - MyText" txt_ret = remove_numbers(txt) puts(1, txt_ret & '\n') txt = "01MyText" txt_ret = remove_numbers(txt) puts(1, txt_ret & '\n') txt = "01 - This is a very, very Long Song title.mp3" txt_ret = remove_numbers(txt) puts(1, txt_ret & '\n') puts(1, "Press any key...") while getc(0) = -1 do end while
Just reply if you need anymore help - but I am wondering why you struggled to write this! Alex