Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 用 \t 替换 NSString 中的选项卡
根据标题:将\t文本文件加载到 NSString 时,有没有办法将制表符()转换为空白?我正在尝试转换文本文件,他们给我带来了麻烦。
\t
这应该有效:
NSString *test = @"hi\tsecond column\t"; NSString *stringWithWhiteSpace = [test stringByReplacingOccurencesOfString:@"\t" withString: @" ";
test只是一个测试字符串,它将是您正在加载的文本文件。stringWithWhiteSpace是带有空格而不是制表符的字符串。
test
stringWithWhiteSpace