import Foundation
let pattern = #"(^.*\/.*-(.*))"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
https://i.ibb.co/cb1sZCc/featured-crown-dark-turquoise.png
https://i.ibb.co/9qVswyn/featured-crown-gold.png
https://i.ibb.co/fxQPh6q/featured-crown-gray.png
https://i.ibb.co/zxZJGj9/featured-crown-green.png
https://i.ibb.co/sgV0QJh/featured-crown-magenta.png
https://i.ibb.co/mNFdFMJ/featured-crown-orange.png
https://i.ibb.co/hDSZ7wn/featured-crown-original.png
https://i.ibb.co/nCvqhKG/featured-crown-purple.png
https://i.ibb.co/d71yh86/featured-crown-red.png
https://i.ibb.co/Smc4y6B/featured-crown-saddle-brown.png
https://i.ibb.co/GPP4mRJ/featured-crown-teal.png
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let substitutionString = #" { "id": "string", "heading": "Heading: $2", "subheading": "Subheading: $2", "image": "$1", "weblink": "http://wattpad.com/home", "applink": "wattpad://home" },"#
let result = regex.stringByReplacingMatches(in: testString, range: stringRange, withTemplate: substitutionString)
print(result)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Swift 5.2, please visit: https://developer.apple.com/documentation/foundation/nsregularexpression