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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -