I have following string
String str = 'replace :) :) with some other string';
And I want to replace first occurance of :) with some other string
And I used str.replaceFirst(':)','hi');
it gives following exception
‘Unmatched closing ‘)”
I tried using replace function but it replaced all occurance of :).
Apache Jakarta Commons are often the solution for this class of problems. In this case, I would have a look at commons-lang, espacially StringUtils.replaceOnce().