| | |
| | | } |
| | | |
| | | /** |
| | | * 返回格式化后的手机号,加空格 |
| | | */ |
| | | fun String?.formatPhone(): String { |
| | | if (!isValidPhone()) { |
| | | return this?:"" |
| | | } |
| | | return "${this!!.substring(0,3)} ${substring(3,7)} ${substring(7)}" |
| | | } |
| | | |
| | | /** |
| | | * 返回格式化后的手机号,加空格 |
| | | */ |
| | | fun String.ellipsize(maxCount:Int): String { |
| | | if (isNullOrEmpty()||length<maxCount){ |
| | | return this |
| | | } |
| | | return "${this!!.substring(0,maxCount)}…" |
| | | } |
| | | |
| | | /** |
| | | * 隐藏身份证号,必须不为null并且length大于10才返回处理后的字符串 |
| | | */ |
| | | fun String?.hideIdCard(): String { |
| | |
| | | return substring(0, 6) + "*****" + substring(length - 4, length) |
| | | } |
| | | |
| | | /** |
| | | * 隐藏銀行卡 |
| | | */ |
| | | fun String?.hideBankCard(): String { |
| | | if (isNullOrEmpty()) { |
| | | return "" |
| | | } |
| | | if (this!!.length < 4) { |
| | | return this |
| | | } |
| | | return "**** **** **** **** " + substring(length - 4, length) |
| | | } |
| | | |
| | | fun String?.isFilePath(): Boolean { |
| | | if (isNullOrEmpty()) { |
| | | return false |