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

    ///
    /// - Parameter font: The font to use for calculating size.
    public func size(withFont font: UIFont) -> CGSize {
        (self as NSString).size(withAttributes: [.font: font])
    }

    /// Returns the height of the string constrained by specified font and size.

        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)
            }
