获取iphone sdk中uitextview数组中的所有超链接?

发布于 2024-08-22 09:26:51 字数 71 浏览 5 评论 0原文

我有一个 UITextView,其中有 5 个超链接和 5 个电话号码。如何在 NSarray 中获取所有这些超链接和电话号码?

I have a UITextView in which i have 5 hyperlinks and 5 phone numbers.How do i get all those hyperlinks and phone numbers in a NSarray?

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

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

发布评论

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

评论(1

随遇而安 2024-08-29 09:26:51

一种选择是使用 RegexKitLitecomponentsMatchedByRegex:方法。然后,您可以使用正则表达式来查找文本的适当部分,并且您将获得以数组形式返回的结果。

您可以使用 RegExr 来试验您的特定正则表达式,并使用“社区”查找预先构建的正则表达式,以查找电话号码和超链接。 (我检查过,它们就在那里!)

RegexKitLite 直接编译到您的应用程序中,因此在 iPhone 上使用它没有问题。祝你好运!

One option is to use RegexKitLite's componentsMatchedByRegex: method. You can then use a regular expression to find the appropriate parts of the text, and you'll get the results returned as an array.

You can use RegExr to experiment with your specific regular expressions, and use the "Community" to find pre-built regular expressions that find phone numbers and hyperlinks. (They're there, I checked!)

RegexKitLite compiles right into your app, so there's no problem using it on the iPhone. Good luck!

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