Last active
April 9, 2017 09:14
-
-
Save dd-han/b6af5421eee5a678fb419e188003c1b6 to your computer and use it in GitHub Desktop.
Taiwan Phone Number formater
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
# Cellphone and 080X-XXX-XXX free/paid phone number | |
s/^09[0-9][0-9]/&-/g; s/^09[0-9][0-9]-[0-9][0-9][0-9]/&-/g; | |
s/^0[1-7]0/_&-/g; | |
s/^080[0-9]/&-/g; s/^080[0-9]-[0-9][0-9][0-9]/&-/g; | |
# ref: https://zh.wikipedia.org/wiki/中華民國長途電話區號表 | |
# normal home phone number | |
s/^037/(037) /g; | |
s/^049/(&) /g; | |
s/^0826/(&) /g; | |
s/^082/(&) /g; | |
s/^0836/(&) /g; | |
s/^089/(&) /g | |
s/^0[2-8]/(&) /g; | |
# last four digital always in same group | |
s/[0-9][0-9][0-9][0-9]$/-&/g | |
# 070 not region code, remove them | |
s/^_//g |
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
echo 0212341234 | sed -f sed_file | |
echo "(02) 1234-1234" | |
echo 031231234 | sed -f sed_file | |
echo "(03) 123-1234" | |
echo 037121234 | sed -f sed_file | |
echo "(037) 12-1234" | |
echo 0412341234 | sed -f sed_file | |
echo "(04) 1234-1234" | |
echo 047121234 | sed -f sed_file | |
echo "(04) 712-1234" | |
echo 048121234 | sed -f sed_file | |
echo "(04) 812-1234" | |
echo 0491231234 | sed -f sed_file | |
echo "(049) 123-1234" | |
echo 051231234 | sed -f sed_file | |
echo "(05) 123-1234" | |
echo 061231234 | sed -f sed_file | |
echo "(06) 123-1234" | |
echo 071231234 | sed -f sed_file | |
echo "(07) 123-1234" | |
echo 081231234 | sed -f sed_file | |
echo "(08) 123-1234" | |
echo 089121234 | sed -f sed_file | |
echo "(089) 12-1234" | |
echo 082121234 | sed -f sed_file | |
echo "(082) 12-1234" | |
echo 0826 | sed -f sed_file | |
echo "(0826)" | |
echo 083611234 | sed -f sed_file | |
echo "(0836) 1-1234" | |
echo 0900123123 | sed -f sed_file | |
echo "0900-123-123" | |
echo 0800123123 | sed -f sed_file | |
echo "0800-123-123" | |
echo 07012341234 | sed -f sed_file | |
echo "070-1234-1234" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment