I have been trying to get the verification of a a String which contains a LRC file
http://en.wikipedia.org/wiki/LRC_%28file_format%29
and would like through regex, verify if the format of the file its correct or not.
It will be valid, not just line starting with [mm:ss.xx] but also [mm:ss] since, it will be by default xx=00
So the idea it would be to return if the file its corrected or not, including
also the ID Tags that may appear in the file.
Thanks in advance
I guess you would need to loop over every line in the file and test it against a regex to check if it matches the syntax. If the regex ever fails then you would obviously return
false. An appropriate regex is probably something like:Which will match both:
And gives you a second matching group in case you want to grab the lyrics.
For matching the tags you probably want a regex along the lines of:
Which will match:
Though this assumes there are no numbers in the tag name. It gives you two capturing groups for both the tag name and value.
In order to do what you want I have created a jsFiddle which I think demonstrates the functionality you want. It assumes the LRC data is separated by
\ncharacters. The example method is as follows: