UNPKG

util-helpers

Version:

一个基于业务场景的工具方法库

18 lines (15 loc) 631 B
import { toString } from 'ut2'; function formatMobile(mobileNo, options) { if (mobileNo === void 0) { mobileNo = ''; } var _a = (options || {}).spaceMark, spaceMark = _a === void 0 ? ' ' : _a; var regChar = new RegExp(spaceMark, 'g'); var realValue = toString(mobileNo).replace(regChar, '').substring(0, 11); if (realValue.length > 7) { return realValue.replace(/^(...)(....)/g, "$1".concat(spaceMark, "$2").concat(spaceMark)); } if (realValue.length > 3) { return realValue.replace(/^(...)/g, "$1".concat(spaceMark)); } return realValue; } export { formatMobile as default };