按分隔符拆分字符串 [英] Split string by delimiter

查看:171
本文介绍了按分隔符拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的找不到这个答案...

I really can't find this answer...

我在XCode中有一个名为myString的多行NSString,它是一个HTML代码。我需要按行导航字符串,例如:

I have multiline NSString called myString in XCode, and it is a HTML code. I need to navigate the string by lines, for example:

myString = @"<html>"
            "<body>"
            "<head><title>My Page</title>";

如何每行访问一行?喜欢:

How can I access line per line? like:

LineOne = myString.Lines[0];
LineTwo = myString.Lines[1];

如何在XCode中执行类似的操作???

How can I do something like that in XCode???

我需要像Delphi中的Memo组件...

I need something like the Memo component in Delphi...

推荐答案

大多数html字符串都有(用于分隔行的新行分隔符

The most html strings will have (mostly invisible) newline delimiters for separating the line

NSArray *lines = [myHtmlString componentsSeparatedByString: @"\n"];
NSString *lineOne = lines[0];
...

这篇关于按分隔符拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆