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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -