java - Replace Last Occurrence of a character in a string -


this question has answer here:

i having string this

"position, fix, dial" 

i want replace last double quote(") escape double quote(\")

the result of string

"position, fix, dial\" 

how can this. aware of replacing first occurrence of string. don't know how replace last occurrence of string

string str = "\"position, fix, dial\""; int ind = str.lastindexof("\""); if( ind>=0 )     str = new stringbuilder(str).replace(ind, ind+1,"\\\"").tostring(); system.out.println(str); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -