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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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!