import Foundation
let pattern = #"(?s)<div>.*?<\/div>"#
let regex = try! NSRegularExpression(pattern: pattern)
let testString = #"""
<div class="scrollable " style="height: 200px;">
<div>
<p>CO-Schrank: nicht benötigtes ausbauen</p>
<p><strong>________________________________________________________________________</strong></p>
<p><strong>==> wird nicht mehr benötigt!<br /></strong>z-B.: IUC</p>
<p>CO-Management in Gen. 2 implementieren</p>
<ol>
<li>Ausbau der PCI-Karten aus ZKA-PC in CO-PC- PC-Sys 02 TP 55, 56, 61 sind noch Profibus im ZKA-PC ==> in CO-PC- PC-Sys 02 greift dann auf CO-PC für Datenaufzeichnung => Betrieb wieder aufnehmen</li>
<li>Ausbau der IUC</li>
<li>Testaufbau am CO-PC für den CO-Algorithmus und Datenspeicherung</li>
<li>Gen. 2 in CO-Management implementieren- pro Prüfling 3 Min. (3 Min. x 48 HG x 10 Messungen) = 1440 Min. = 24 h- Messzeit 1-2 Min.</li>
</ol>
</div></div>
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
if let firstMatch = regex.firstMatch(in: testString, range: stringRange) {
let result: [String] = (1 ..< firstMatch.numberOfRanges).map { (testString as NSString).substring(with: firstMatch.range(at: $0)) }
print(result)
} else {
print("No matches were found.")
}
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