import Foundation
let pattern = #".*"email":"(.*?)".*emailActivationSecret":"(.*?)".*"_id":"(.*?)".*"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
"__v":0,"language":"en","jobTitle":"Executive","firstName":"wer","lastName":"wre","email":"fde+98989@gmail.com","phone":"+1 213-321-3232","_companyId":"5723erera8b2196fdaer9502b86dc7","accountStatus":"UNVERIFIED","role":"ADMIN","emailActivationSecret":"XD1EererreQyVLFn1IjJg7QQNcDz9RLZ1xrKnl84XI5Nb5","_id":"5723a8b21er96fwereeda9ewree502b86dc8","products":[],"created":"2016-04-29T18:32:18.700Z"}
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let substitutionString = #"webserver-wat:3001/activateAccount?email=$1&secret=$2&companyId=$3"#
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