I'm writing a program that will take sheet music (chords above lyrics) and transpose the key. I'm choosing to split up a song String, manipulate the chord names and build a new String. My approach is to split the song into lines String[] holder = song.split("\\n+"); Then, take each line and split based on whitespace String[] oneLine = s.split("\\s");
When building the new string, maintaining the original spacing is absolutely crucial. My problem is that by splitting on //s I lose all history of spacing. Can anyone suggest a solution to my problem?
Here is an example song
String song = "G Em C D\nSome Lyrics Go Here\nG C D\nOther Lyrics Go Here";
Currently my transposed song would look like this...
AF#mDE
Some Lyrics Go Here
ADE
Other Lyrics Go Here
G Em C Dyou want to change toA F#m D Ewith the white-space before? But because you trying to change it than the white-space become disappear? Can you post the code when you trying to change the key?