Last active
August 23, 2016 21:52
-
-
Save svetlanama/59c0259626b532208ae82534e77998e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Apply mask to credit card number | |
func applyMask(number: String) -> String { | |
let mask = "%2A%2A%2A+%2A%2A%2A%2A+%2A%2A%2A%2A+" | |
let startIndex = number.startIndex | |
let range = startIndex.advancedBy(1) ..< number.endIndex.advancedBy(-4) | |
let substring = number.substringWithRange(range) | |
let replacedWithMask = number.stringByReplacingOccurrencesOfString(substring, withString: mask) | |
return replacedWithMask | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment