From d2364ff660c41b10bdf00b4768b12c6dd40f8c10 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Wed, 1 Jan 2025 08:27:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Adds=20code=20comments=20for=20t?= =?UTF-8?q?he=20regex=20used.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RSCore/Sources/RSCore/Shared/String+RSCore.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/RSCore/Sources/RSCore/Shared/String+RSCore.swift b/RSCore/Sources/RSCore/Shared/String+RSCore.swift index 1c5add27b..9b4dc32cc 100644 --- a/RSCore/Sources/RSCore/Shared/String+RSCore.swift +++ b/RSCore/Sources/RSCore/Shared/String+RSCore.swift @@ -189,6 +189,22 @@ public extension String { /// Removes an HTML tag and everything between its start and end tags. /// + /// The regex pattern `.*?` explanation: + /// - `<` matches the literal `<` character. + /// - `tag` matches the literal parameter provided to the function, e.g., `style`. + /// - `>` matches the literal `>` character. + /// - `.*?` + /// - `.` matches _any_ character **except** a new line + /// - `*` will match zero or more of the preceeding character, in this case _any_ + /// character + /// - `?` switches the matching mode to [lazy](https://javascript.info/regexp-greedy-and-lazy) + /// so it will match as few as characters as possible before satisfying the rest of the pattern. + /// - `<` matches the literal `<` character. + /// - `/` matches the literal `/` character. + /// - `tag` matches the literal parameter provided to the function, e.g., `style` + /// - `>` matches the literal `>` character. + /// + /// /// - Parameter tag: The tag to remove. /// /// - Returns: A new copy of `self` with the tag removed.