well apologise at first because its more like asking for help then asking a question , so am a noob in Android development and i want to write a function which i've written for iOS in swift , so if anybody can help me with this then it'll be great :
i want to convert a String from String1 = "Guardians Of the Galaxy(G.T.G)" into
String2 = "GTG" all i want to is to get the value which is inside the brackets and remove the
spaceLessFullForm = "Catch Me if You Can"
let SpaceLessFullForm = Fullform.condensedWhitespace
let delimiters: NSCharacterSet = NSCharacterSet(charactersInString: "()")
var splitString: [AnyObject] = SpaceLessFullForm.componentsSeparatedByCharactersInSet(delimiters)
let substring: String = splitString as! String
let dotLessString = substring.stringByReplacingOccurrencesOfString(".", withString: "")
let upperCaseFirstCharcters = dotLessString.stringByReplacingOccurrencesOfString(" ", withString: "")
upperCaseFirstCharcters = "CMIUC"
Try this way..
String kek = "Guardians Of the Galaxy(G.T .G . V)"; int fInd = kek.indexOf("(") + 1; int lInd = kek.indexOf(")"); String kek1 = kek.substring(fInd, lInd); String kek2 = kek1.replace(".", "").replace(" ", ""); Toast.makeText(getApplicationContext(), kek2, Toast.LENGTH_SHORT) .show();
Result will be : GTGV