Answers for "allowed filename characters swift"

0

allowed filename characters swift

extension String {
    func convertToValidFileName() -> String {
        let invalidFileNameCharactersRegex = "[^a-zA-Z0-9_]+"
        let fullRange = startIndex..<endIndex
        let validName = replacingOccurrences(of: invalidFileNameCharactersRegex,
                                           with: "-",
                                        options: .regularExpression,
                                          range: fullRange)
        return validName
    }
}
Posted by: Guest on October-16-2020

Code answers related to "allowed filename characters swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language