This commit is contained in:
cdricms
2025-12-06 16:33:17 +01:00
parent 7be99711e1
commit 043de16a16
31 changed files with 594 additions and 1674 deletions

View File

@@ -0,0 +1,12 @@
import Foundation
extension String {
public func camelCaseToSnakeCase() -> String {
let pattern = "([a-z0-9])([A-Z])"
let regex = try! NSRegularExpression(pattern: pattern, options: [])
let range = NSRange(location: 0, length: self.count)
return regex.stringByReplacingMatches(
in: self, options: [], range: range, withTemplate: "$1_$2"
).lowercased()
}
}