import Foundation
let pattern = #"(<p value="id">(?=1445).+\R.+<p value="IP">)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(.+)"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
<list name="ItemList">
<item>
<p value="id">1445</p>
<p value="IP">10.25.30.19</p>
<p value="Prflen">26</p>
</item>
<list name="ItemList">
<item>
<p value="id">1499</p>
<p value="IP">10.40.50.53</p>
<p value="Prflen">26</p>
</item>
<list name="ItemList">
<item>
<p value="id">1445</p>
<p value="IP">10.45.70.19</p>
<p value="Prflen">26</p>
</item>
<list name="ItemList">
<item>
<p value="id">1446</p>
<p value="IP">10.77.90.55</p>
<p value="Prflen">26</p>
</item>
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let substitutionString = #"\110.25.30.19\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