从 HTML 标记(Regex、NScanner、Hppple)获取 URL 的最快方法是什么?

发布于 2024-11-27 14:07:45 字数 226 浏览 3 评论 0原文

我发现了 3 种不同的方法来获取 HTML 字符串中 img 标记的 src 属性的值。

  1. 使用 RegexKitLite 的正则表达式。
  2. 使用 TFHpple HTML 解析器
  3. 使用 NSSCanner 扫描 HTML 字符串。

那么我必须使用哪种方法来优化 iPhone 应用程序的性能呢?

I found 3 different way to get the value of the src attribute of an img tag in an HTML string.

  1. With a Regex using RegexKitLite.
  2. With TFHpple HTML parser
  3. Using a NSSCanner to scan the HTML string.

So which way I must use to optimize performance of my iPhone app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

国际总奸 2024-12-04 14:07:45

也许不是最快的,但正则表达式是最通用和可移植的方法。除非你真的每秒进行数百次解析,否则你不会注意到不使用最快的方法所带来的性能损失。

我在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文