What about something like this:
String replaceFirstFrom(String str, int from, String regex, String replacement)
{
String prefix = str.substring(0, from);
String rest = str.substring(from);
rest = rest.replaceFirst(regex, replacement);
return prefix+rest;
}
// or
s.substring(0,start) + s.substring(start).replaceFirst(search, replace);
just 1 line of code ... not a whole method.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…