I’m on the way to write a tabulator-Editor for my music project and need to format the chordnames. Everything works fine except special bass- oder high-notes f.e. Am7/bbc#.
In that example it should look like Am7/BbC# and the chars behind / or should be <sup>
in html.
So my question is: How can I write an expression with replace /bb, c# or only /a, f?
It’s not necessary that every chord has a/* or a* (bass- or highnote)
Thanks a lot
Detlef
At the moment I format my Chords like this:
function formatChords(obj, value) {
if(!value) return;
var newValue = value;
var formated = newValue.replaceAll('#', '<sup class="superSS">#</sup>');
formated = formated.replaceAll('b', 'B');
formated = formated.replaceAll('bb', 'B<sup class="superSS">b</sup>');
formated = formated.replaceAll('BB', 'B<sup class="superSS">b</sup>');
formated = formated.replace(new RegExp("\d", "g"), '<sup class="superSS">$&</sup>');
formated = formated.charAt(0).toUpperCase() + formated.slice(1);
obj.html(formated);
}
Detlef Winkel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.