I have some lines of song lyric and chords, with format like below:
And need to convert just like below:
I am able to get the chord keys, but getting trouble when trying to put them to each column on each line.
This is what I've done:
_read({required String text}) {
var result = text.split('\n');
RegExp re = RegExp(r"^[A-G\d#b\s/-/m]*$(?:\r\n)?", caseSensitive: false, multiLine: true);
var chords = '';
for (final i in re.allMatches(text)) {
chords = '$chords\n${(i[0]) ?? ''}';
}
var arrChords = chords.split('\n');
for (int j = 0; j < arrChords.length; j++) {
final i = arrChords[j];
print(i);
if (i.isNotEmpty) {
// I am stuck from here
var lineChords = i.split(' ');
for (int k = lineChords.length - 1; k > 0; k--) {
final e = lineChords[k];
if (e.isNotEmpty) {
var sRight = result[j + 1].substring(k);
var sLeft = result[j + 1].substring(0, k);
print(sLeft + sRight);
// result[j + 1] = '$sLeft[$e]$sRight';
}
}
}
}
// return result;
}
Edit : Answer/suggestion using C#, JS, or Dart are welcome