从 HTML 标记(Regex、NScanner、Hppple)获取 URL 的最快方法是什么?
我发现了 3 种不同的方法来获取 HTML 字符串中 img
标记的 src
属性的值。
- 使用 RegexKitLite 的正则表达式。
- 使用 TFHpple HTML 解析器
- 使用 NSSCanner 扫描 HTML 字符串。
那么我必须使用哪种方法来优化 iPhone 应用程序的性能呢?
I found 3 different way to get the value of the src
attribute of an img
tag in an HTML string.
- With a Regex using RegexKitLite.
- With TFHpple HTML parser
- Using a NSSCanner to scan the HTML string.
So which way I must use to optimize performance of my iPhone app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许不是最快的,但正则表达式是最通用和可移植的方法。除非你真的每秒进行数百次解析,否则你不会注意到不使用最快的方法所带来的性能损失。
我在 iPhone 上使用大量正则表达式在用户输入时进行用户输入验证文本(因此肯定会看到滞后)。从来没有任何问题。
Maybe not the fastest, but RegEx is imho the most versatile and portable method. And unless you're really doing hundreds of parses per second, you won't notice the performance hit you'll get by not using the fastest method around..
I use lots of regexes on iPhone for user input validation while the user is entering text (so a lag would certainly be seen). Never had any problems.