debugging phase of user creation process

This commit is contained in:
talksik
2021-12-18 17:28:11 -08:00
parent 23a2219863
commit 71f5aff78c
8 changed files with 154 additions and 36 deletions
@@ -0,0 +1,23 @@
//
// CustomExtensions.swift
// nirvana-ios
//
// Created by Arjun Patel on 12/18/21.
//
import Foundation
extension String {
// custom function to give (949)920-0392 and get out the right thing
func applyPatternOnNumbers(pattern: String, replacementCharacter: Character) -> String {
var pureNumber = self.replacingOccurrences( of: "[^0-9]", with: "", options: .regularExpression)
for index in 0 ..< pattern.count {
guard index < pureNumber.count else { return pureNumber }
let stringIndex = String.Index(utf16Offset: index, in: pattern)
let patternCharacter = pattern[stringIndex]
guard patternCharacter != replacementCharacter else { continue }
pureNumber.insert(patternCharacter, at: stringIndex)
}
return pureNumber
}
}