import Foundation
let pattern = #"^"(.*)" (.*), (.*)"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
Description
"Mulligan" neutered male, Brindle Bullmastiff
"Tiny" male, tan and white Boxer mix
"Charlie" neutered male, black and white Labrador Retriever mix
"Nala" spayed female, white and brown brindle Pit Bull mix
"Lexie" female, white and black Pit Bull
"Holly" Spayed female, white Labrador/Pitbull mix
"Lincoln" male, fawn and white Pit Bull Terrier
"Sparkles" spayed female, Brindle Plott Hound mix
"Missy" Spayed Female, red/white Pitbull mix
"Rita" female, brown Australian Shepherd
"Miles Davis" female, gold/white Golden Retriever
"Lacy" spayed female, Labrador Retriever Mix
"Clementine" spayed female, black and white Austrailian Cattle dog
"Coronel" Male, Tan/Black German Shepherd mix
"Lady Bug" spayed female, white/black Pit bull/Jack Russell mix
"Buddy" male, blue brindle and white Pitbull mix
"Boomer" neutered brown Pit Bull Mix
"Weezer" female, Tan/Brown German Shepherd
"Little Girl" spayed female, brown brindle and white Bull Terrier
"Diva" intact female, tri-color Pit Bull
"Jack" neutered male, red/white Labrador Retriever mix
"Salty" male, brown and white Boxer
"G" male, brown Pit Bull/Boxer mix
"Keely" spayed female, Red Labrador Retriever mix
"Tyson" neutered male, German Shepherd
"Tug" male, brown merle and white Queensland Heeler mix
"Shebba" female, white Pit Bull mix
"Blue" male, blue Pit Bull mix
"Pinky" female, white Boxer mix
"Ladybird" Spayed female, yellow brindle and white Pit Bull mix
"Dozer" neutered male, white and red Rhodesian Ridgeback
"Lahlo" spayed female, tan Boxer mix
"Maya" spayed female, brown/white Pitbull mix
"Cinnamon" female, red and white Border Collie
"Taz" neutered male, brown brindle Boxer mix
"Lily" female, black and white Chihuahua
"Abbo" neutered male, white/brown Great Pyrenees mix
"Milo" neutered male, white/brown, German Short-haired Pointer
"Lia" spayed female, white/black Pit Bull/Jack Russell mix
"Sissy" female, tan and black German Shepherd
"Nippy" female, black and tan Shepherd mix
"Ginger" spayed female, red and white American Fox Terrier mix
"Jonah" female, brown and white Pit Bull mix
"Diego" neutered male, cream and white Great Pyrenees
"June" female, Brindle Pit Bull Terrier
"Maia" female, white/tan Pit Bull mix
"Iko" neutered male, Brown Brindle Catahoula mix
"Zues" neutered male, blue and white Great Dane
"Tank" neutered, black/grey German Wire-haired Pointer
"Bumpy" neutered male, white and black Bull Terrier
"Negro" neutered male, black, tan and white Chihuahua mix
"Lucy" spayed female, brown brindle and white Boxer mix
"Austin" male, red merle Australian Shepherd
"Aries" spayed female, blue Cane Corso
"Bella" spayed female, Tan and White Pit Bull mix
"Gucio" male, black Giant Schnauzer
"Kilo" neutered male, red and white Pit Bull mix
"Chuy" spayed female, brown brindle and white Boxer mix
"Flint" neutered male, blue Blue Lacy mix
"Sydney" spayed female, Tricolor/Black Beagle
"Sunny" Neutered Male, Brown/Tan Shepherd mix
"Lucky" male, black and tri-colored Chihuahua
"Cleo" female, black Labrador Retriever mix
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let substitutionString = #"$1\t$2\t$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