How to get only link from this string?
<p>I want to get only the link from this string:</p>

<pre><code>"&lt;p&gt;&lt;a href=\"https://www.youtube.com/watch?v=i2yscjyIBsk\"&gt;https://www.youtube.com/watch?v=i2yscjyIBsk&lt;/a&gt;&lt;/p&gt;\n"
</code></pre>

<p>I want output as <code>https://www.youtube.com/watch?v=i2yscjyIBsk</code></p>

<p>So, how I can I achieve it?</p>

<p>I have tried:</p>

<pre><code>func matches(for regex: String, in text: String) -&gt; [String] {
do {
let regex = try NSRegularExpression(pattern: regex)
let nsString = text as NSString
    let results = regex.matches(in: text, range: NSRange(location: 0, length: nsString.length))
    return results.map { nsString.substring(with: $0.range)}
} catch let error {    
}
</code></pre>

<p>And tried this regex: <code>"&lt;a[^&gt;]+href=\"(.*?)\"[^&gt;]*&gt;.*?&lt;/a&gt;"</code></p>

<p>But still I can't figure it out.</p>