ios - How to parse a NSString -


the string myagent(9953593875).amt:rs.594 , want extract 9953593875 it. here tried:

nsrange range  =  [fedetails rangeofstring:@"."]; nsstring *truncatedfedetails = [fedetails substringwithrange:nsmakerange(0, range.location)]; nslog(@"truncatedstring-->%@",truncatedfedetails); 

this outputs: truncatedstring-->amzagent(9953593875)

or this:

nsstring *string = @"myagent(9953593875).amt:rs.594.";  nsrange rangeone = [string rangeofstring:@"("]; nsrange rangetwo = [string rangeofstring:@")"];  if (rangeone.location != nsnotfound && rangetwo.location != nsnotfound) {     nsstring *truncatedfedetails = [string substringwithrange:nsmakerange(rangeone.location + 1, rangetwo.location - rangeone.location - 1)];     nslog(@"%@",truncatedfedetails);  } 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -