Created
February 1, 2018 14:25
-
-
Save y8k/4dbb0a32ca3c716458d54b77fec70362 to your computer and use it in GitHub Desktop.
Convert phone number consist of digits to with dash
This file contains 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
let phoneNumber = "01026979999" | |
// REGEX FOR KOREAN CELL PHONE NUMBER FORMAT | |
let expression = "(\\d{3})(\\d{\(phoneNumber.count - 7)})(\\d{4})" | |
let result = phoneNumber.replacingOccurrences(of: expression, with: "$1-$2-$3", options: .regularExpression, range: nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment