     ///
     /// - Parameter font: The font to use for calculating size.
     public func size(withFont font: UIFont) -> CGSize {
-        (self as NSString).size(withAttributes: [.font: font])
+        nsString.size(withAttributes: [.font: font])
     }
 
     /// Returns the height of the string constrained by specified font and size.

        options: NSStringDrawingOptions = .usesLineFragmentOrigin,
        constrainedToSize: CGSize
    ) -> CGSize {
        let expectedRect = (self as NSString).boundingRect(
            with: constrainedToSize,
            options: options,
            attributes: [.font: font],

        do {
            let regex = try NSRegularExpression(pattern: pattern, options: [])
            let results = regex.matches(in: self, range: NSRange(startIndex..., in: self))
            return results.map {
                nsString.substring(with: $0.range)
            }
