I simply need to replace:
with in string
You can do a regular expression search, with a template in the replacement
string: For each match, the ,
\\n
, \\n
let string = "<p>hello</p> my <div>Doggy</div>"
let newString = string.replacingOccurrences(of: "<p>|<div>", with: "\n$0", options: .regularExpression)
$0
template is replaced by what actually matched the pattern.