import Foundation
let pattern = #"""
<p>(\s?]]><\/footer>
<\/content>)
"""#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
<?xml version="1.0" encoding="utf-8"?>
<content>
<title />
<meta-description />
<meta-robots />
<heading1 />
<canonical />
<footer><![CDATA[ Anniston is a city undergoing a period of rebirth, with some of its buildings being refurbished while new real estate is also cropping up. Most of the city is still full of historic buildings which have been refurbished for use ranging from government offices to churches. </p><p></p><p>Situated on the slope of the Blue Mountain, it has a great climate which makes its environment friendly to different species of birds, mammals and reptiles. One can indulge in peaceful outdoor activities like bird watching, or hiking the Chief Ladiga Trail and the Silver Comet Trail as well as the Blue Ridges and the Appalachian Mountains.</p><p></p><p>This region has long been a cultural center for the northeastern part of Alabama. It’s full of music, history, art and theatre. You can attend the annual Knox Concert Series which produces some of the best world-renowned music and dance productions. There is also a local theatre, the Community Actor’s Studio Theatre, that not only puts on plays, musicals and skits with the help of local performers, but it also provides art education to local children for free. This is just a taste of what this city can offer in terms of entertainment and education. Some of the other well-established local entertainment venues include Wren’s Nest and Your Local Art Studio.</p><p></p><p>This area has also a wide array of shopping malls including Quintard Mall and Oxford Exchange. Some of the other local shopping venues include major chains like Walgreens, Midtown Outlet and Fred’s Store. Anniston has also some of the best restaurants that serve both local and international cuisines ranging from Italian, Chinese and even Japanese seafood.</p><p></p><p>Moreover, the city is also known for its historic museums which house aged artifacts, mummies and dioramas of wildlife. These museums include the Anniston Museum of Natural History as well as the Berman Museum of World History. Together they also provide a great avenue for learning about the rich history of this city.</p><p></p><p>As for getting in and around Anniston, the Anniston Eastern and Western bypass runs through city as well as a number of state routes and highways, making the city’s transport system easy to navigate. So if you were thinking of relocating, Anniston, Alabama is a great place to be. Search our site to find your next home. </p><p></p><p> Top 1: [BrandRank1]</p><p>Top 2: [BrandRank2]</p><p> Top 3: [BrandRank3]</p><p> Average Plan Price [AveragePlanPrice]</p><p> Price Per Foot: [PricePerFoot]</p><p> ]]></footer>
</content>
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let substitutionString = #"$1"#
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