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

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -