this question has answer here:
i have following code removing characters strings representing numbers:
nscharacterset *characterstokeep = [nscharacterset charactersetwithcharactersinstring:@"0123456789"]; nscharacterset *characterstoberemoved = [characterstokeep invertedset]; nsstring *mystring = [dictionary objectforkey:@"mykey"]; mystring = [mystring stringbytrimmingcharactersinset:characterstoberemoved]; mystring = [mystring stringbyreplacingoccurrencesofstring:@"," withstring:@""];
after method stringbytrimmingcharactersinset:
, characters comma removed. after call stringbyreplacingoccurencesofstring:
comma removed. why isn't removed after first call?
here sample of mystring looks after each line of code:
mystring = " $9,959 " mystring = "9,959" mystring = "9959"
i tried
nscharacterset *characterstoberemoved = [nscharacterset decimaldigitcharacterset];
and got same result.
stringbytrimmingcharactersinset: trims characters ends of string, not on inside.
Comments
Post a Comment