The requirement is very simple. It is to match the hyperlink from a piece of text. The basic practice is to use a regular expression for matching. But there is such a problem.
Most regular expressions for identifying URLs on the Internet can be correctly identified if there is spaces at the end of the URL. For example.
I am a Chinese https://github.com/TinyQ or a Chinese
However, if the space following TinyQ is removed. The matched "" will be connected.
A lot of regular expressions were replaced to solve the problem. Paste the code here:
NSError ** regulaStr = * regex = & * response = [regex matchesInString: options: range: NSMakeRange (, [(NSTextCheckingResult * match * substringForMatch = [NSLog (@ "substringForMatch ");
}
Here we will make an update. The following regular expression is also acceptable. And it should be better.
For example, Explorerwww.chiphell.com /. It can also be identified
(Http [s] {} | ftp): // [a-zA-Z0-9 \\. \-] + \\. ([a-zA-Z] {2, 4}) (: \ d + )? (/[A-zA-Z0-9 \\.\\-~! @ # $ % ^ & * +? : _/= <>] *)?) | (Www. [a-zA-Z0-9 \. \-] + \. ([a-zA-Z] {2, 4}) (: \ d + )? (/[A-zA-Z0-9 \\.\\-~! @ # $ % ^ & * +? : _/= <>] *)?)