objective-c – 按空格数分割NSString

栏目: Objective-C · 发布时间: 5年前

内容简介:翻译自:https://stackoverflow.com/questions/7537118/split-nsstring-by-number-of-whitespaces

我有一个NSString,其中包含一些由未知数量的空白字符分隔的值.例如:

NSString* line = @"1 2     3";

我想将NSString分成如下值的NSArray:{@“1”,@“2”,@“3”}.

获取由@“”分隔的组件,并从结果数组中删除所有对象,如@“”.
NSString* line = @"1 2     3";
NSMutableArray *array = (NSMutableArray *)[line componentsSeparatedByString:@" "];
[array removeObject:@""]; // This removes all objects like @""

翻译自:https://stackoverflow.com/questions/7537118/split-nsstring-by-number-of-whitespaces


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Data Structures and Algorithms in Java

Data Structures and Algorithms in Java

Robert Lafore / Sams / 2002-11-06 / USD 64.99

Data Structures and Algorithms in Java, Second Edition is designed to be easy to read and understand although the topic itself is complicated. Algorithms are the procedures that software programs use......一起来看看 《Data Structures and Algorithms in Java》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具