Suggestion for improving string::replaceSection()


#1

i am getting a juce assertion in the following line:

tempchordstring = textEntered.replace(sRoot1+sRoot2,T(""),true);

this occurs if the result of the replace would be a null string.

this appears to be due to a juce assertion inside replacesection at :

String result (newTotalLen, (int) 0);

I realise there is a seperate String::removeCharacters () method, but it does not have the case sensitivity option that i need.

can i suggest that you either :

  1. amend removeCharacters() so we can specify case sensitivity

or/and

  1. amend the replacesection() code so that if newTotalLen is zero the code just returns a null string.

#2

Ok, thanks. It does look like replaceSection should cope with that without complaining. Very simple to fix - I’ll add a line:

[code] if (newTotalLen <= 0)
return String::empty;

String result (newTotalLen, (int) 0);

[/code]