我需要在一个字符串中找到多个URL。我正在使用的正则表达式是
(https?:\/\/.*\.(?:png|jpg))
并且字符串是Newhttps://www.findregexhere.com/newimage.pngfrhttps://www.findregexhere.com/newimage.pngnewimage
这是我正在使用的代码
let regex = try NSRegularExpression(pattern: "https?:\/\/.*\.(?:png|jpg)$", options: .caseInsensitive)
let nsString = text as NSString
let results = regex.matches(in: text, range: NSRange(location: 0, length: nsString.length))
但是结果给了我这个
https://www.findregexhere.com/newimage.pngfrhttps://www.findregexhere.com/newimage.png