How to remove whitespace in a string?

后端 未结 13 2207
天涯浪人
天涯浪人 2020-12-17 08:12

I have a string say \"Allentown, pa\"

How to remove the white space in between , and pa using objective c?

13条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 08:44

    NSString *sample = @" string with whitespaces";
    NSString *escapeWhiteSpaces = [sample stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    

提交回复
热议问题