[Javascript]parsing LRC lyric

var _current_lyric = new Array();
function convertLRCLyric(inf){
inf += "n";
var lyric = inf.match(/([(d{2}:d{2}(.d{1,2}){0,1})]){1,}W*n|([(d{2}:d{2}:d{2}(.d{1,2}){0,1})]){1,}W*n/ig);
var l_s = '',l_tt,l_ww,l_i,l_ii;
if(!lyric || !lyric.length){
return;
}
for(l_i=0; l_i<lyric.length ; l_i++){
l_tt = lyric[l_i].match(/([d{2}:d{2}(.d{1,2}){0,1}])|([d{2}:d{2}:d{2}(.d{1,2}){0,1}])/ig);
l_ww = lyric[l_i].replace(/[S+]/ig,'').replace(/n{1,}/ig,'');
for(l_ii=0; l_ii<l_tt.length ; l_ii++){
l_tt[l_ii] = l_tt[l_ii].replace(/[/,'').replace(/]/,'');
if(l_tt[l_ii].search(/d{2}:d{2}:d{2}.d{2}/g)>=0){
_current_lyric[l_tt[l_ii].substring(0,l_tt[l_ii].length-1)] = l_ww;
}else if(l_tt[l_ii].search(/d{2}:d{2}:d{2}.d{1}/g)>=0){
_current_lyric[l_tt[l_ii]] = l_ww;
}else if(l_tt[l_ii].search(/d{2}:d{2}:d{2}/g)>=0){
_current_lyric[l_tt[l_ii]+".0"] = l_ww;
}else if(l_tt[l_ii].search(/d{2}:d{2}.d{2}/g)>=0){
_current_lyric["00:"+l_tt[l_ii].substring(0,l_tt[l_ii].length-1)] = l_ww;
}else if(l_tt[l_ii].search(/d{2}:d{2}.d{1}/g)>=0){
_current_lyric["00:"+l_tt[l_ii]] = l_ww;
}else if(l_tt[l_ii].search(/d{2}:d{2}/g)>=0){
_current_lyric["00:"+l_tt[l_ii]+".0"] = l_ww;
}
}
}
}
包括修补一些不标准的情况。时间配合播放器统一转换成hh:mm:ss.ms(1位)
function parseLyric(da){
_current_lyric = [];
convertLRCLyric(da);
var ly="";
for(var time in _current_lyric){
ly += time + "--" + _current_lyric[time] + "n";
}
alert(ly);
}