Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8295555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:38:44+00:00 2026-06-08T14:38:44+00:00

I was using the code from Kejun’s Blog . I want to parse a

  • 0

I was using the code from Kejun’s Blog .

I want to parse a .lrc (which is basically a lyrics file) so as to get the time variable as well as the string(read lyrics) . I tried out this code and could not seem to get the output .

   <html>
<head> 
<script src="jquery-1.7.1.js"></script>
<script> 
$(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "a.txt",
        dataType: "text",
        success: function (data) {
            parseLyric(data);
        }
    });
});

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;
            }
        }
    }
}

function parseLyric(allText) {
    _current_lyric = [];
    convertLRCLyric(allText);
    var ly = "";
    for (var time in _current_lyric) {
        ly += time + "--" + _current_lyric[time] + "n";
    }
    alert(ly);
}
</script>
</head>
<body>

</body>
</html>

But i keep getting a blank alert . Any help would be great . Thanks in advance .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:38:45+00:00Added an answer on June 8, 2026 at 2:38 pm

    Answer :

    Ok so i built my own parser ,Here is the code

    var contents = " " ;
    function readMultipleFiles(evt) {
        //Retrieve all the files from the FileList object
        var files = evt.target.files;
    
        if (files) {
            for (var i = 0, f; f = files[i]; i++) {
                var r = new FileReader();
                r.onload = (function (f) {
                    return function (e) {
                        contents = e.target.result;
                       processData(contents);
                    };
                })(f);
                r.readAsText(f);
            }
        } else {
            alert("Failed to load files");
        }
    }
    document.getElementById('fileinput').addEventListener('change', readMultipleFiles, false);
    
    
    
    var allTextLines = " ";
    var lyrics = [];
    var tim = [] ;
    var line = " ";
    
    
    // parsing the Lyrics 
    function processData(allText) { // This will only divide with respect to new lines 
        allTextLines = allText.split(/\r\n|\n/);
    
         next();
       } 
     function next()
     {
    for (i=0;i<allTextLines.length;i++)
    {
    if (allTextLines[i].search(/^(\[)(\d*)(:)(.*)(\])(.*)/i)>=0 )// any line without the prescribed format wont enter this loop 
    {
        line = allTextLines[i].match(/^(\[)(\d*)(:)(.*)(\])(.*)/i);
            tim[i] = (parseInt(line[2])*60)+ parseInt(line[4]); // will give seconds 
            lyrics[i]= line[6] ;//will give lyrics 
    
     }
     }  
    
      } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the code from this tutorial to parse a CSV file and
I'm using code from a blog , which is very similar to the code
I am using this code from android developer blog for downloading a BMP file
using code from this site: http://www.saltycrane.com/blog/2008/09/simplistic-python-thread-example/ The code is import time from threading import
I have ported some code from Mingw which i wrote using code::blocks, to visual
I'm using code from this page http://code.google.com/apis/contacts/docs/1.0/developers_guide_js.html to get list of gmail contacts. Actually
I'm using the code from: http://www.swissdelphicenter.ch/torry/showcode.php?id=1103 to sort my TListView, which works GREAT on
I'm using code from other c# app and I can see that in WP7
My main solution is using code from a utility class library, that I wrote
I am developing an android app using code from a normal java application. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.