Created
November 9, 2019 09:21
-
-
Save kujyp/67b8ad602842c07fcadff56960b4dcf7 to your computer and use it in GitHub Desktop.
isPhoneNumberThenEchoYes
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
#!/bin/bash -e | |
function isPhoneNumberThenEchoYes() { | |
if [[ "${1-}" =~ ^([0-9]{2}|[0-9]{3})(-| )?([0-9]{3}|[0-9]{4})(-| )?[0-9]{4}$ ]]; then | |
echo yes | |
else | |
echo no | |
fi | |
} | |
isPhoneNumberThenEchoYes "0" | |
isPhoneNumberThenEchoYes "a" | |
isPhoneNumberThenEchoYes "01012345678" | |
isPhoneNumberThenEchoYes "010-1234-5678" | |
isPhoneNumberThenEchoYes "010-12345678" | |
isPhoneNumberThenEchoYes "010 1234 5678" | |
isPhoneNumberThenEchoYes "010 123 5678" | |
isPhoneNumberThenEchoYes "02 123 5678" | |
isPhoneNumberThenEchoYes "02 1234 5678" | |
isPhoneNumberThenEchoYes "aa1234 5678" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
결과: