I would like to know how is it possible to replace specific characters of an NSString based on some regular expression ([A-G]#?).
More analytically, I have a NSString full of chords and spaces
e.g.
" C A A# B".
What I want is to change these chords based on a dictionary that I made:
@"A", @"A#",
@"A#", @"B",
@"B", @"C",
@"C", @"C#",
@"C#", @"D",
@"D", @"D#",
@"D#", @"E",
@"E", @"F",
@"F", @"F#",
@"F#", @"G",
@"G", @"G#",
@"G#", @"A",
meaning that
A -> A# and A#-> B.
I would also like to keep anything that exists after my basic chord, meaning:
Am -> A#m.
I have already successfully scanned the string and replaced the elements, with the ones I wanted, in a new string, however I can't figure out how can I do that while maintaining the spaces of my initial string.
So to sum things, basically I want this:
" C A A# B"
to become this:
" C# A# B C"
Thank you!