import Foundation
let pattern = #"^(?=.*px\;)([ \S]*)"#
let regex = try! NSRegularExpression(pattern: pattern, options: [.anchorsMatchLines, .caseInsensitive])
let testString = ##"""
.inpt-line {
position: relative;
display: block;
min-height: 56px;
width: 660px;
box-sizing: border-box;
padding: 20px 20px 5px 20px;
color: #787373;
}
.inpt-line label {
font-size: 22px;
font-weight: bold;
text-align: right;
width: 250px;
height: 50px;
}
.inpt-line input,
.inpt-line select {
position: relative;
top: -3px;
height: 30px;
width: 235px;
font-size: 18px;
padding-left: 10px;
box-sizing: border-box;
margin: 0px 15px 5px 10px;
}
input[type="number"] {
width: 80px
}
"""##
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