npm install regex-sugar
默认清除的字符如下
- 英文: !"#$%&'(){}=-/~^|*:+;_
- 中文: 。,!?、;“”‘’~-─…`·:【】〔〕[]﹏$^+=|()<>¥×《》「」
Kind: inner method of clearPunctuations
Returns: string
- cleared string
Param | Type | Description |
---|---|---|
value | string |
a string |
exclude | regexp |
exclude chars |
Example
clearPunctuations('[bookname]-gitbook', /[_\-]/g);
// return bookname-gitbook
Check string is a email address
Kind: inner method of isEmail
Param | Type | Description |
---|---|---|
value | string |
a string |
格式说明
- 1-9 开头, 最少 5 位
Kind: inner method of isQQNumber
Param | Type | Description |
---|---|---|
value | string |
a string |
判断字符串是否完全由中文字符组成
Kind: inner method of zh/chars
Param | Type | Description |
---|---|---|
value | string |
待检查的字符串 |
ext | string |
需要排除的字符串列表, 请注意使用正则转义字符 |
格式说明
- 15 位或 18 位
- 1~6 位为地区代码
- 7~14 位为出生年月日
- 15~17 位为顺序号,是县、区级政府所辖派出所的分配码
- 18 位为效验位
Kind: inner method of zh/isIDCardNumber
Param | Type | Description |
---|---|---|
value | string |
a string |
- zh/isPhoneNumber
- ~isMobilePhoneNumber(value) ⇒
boolean
- ~isFixedPhoneNumber(value) ⇒
boolean
- ~isMobilePhoneNumber(value) ⇒
格式说明
电信
- 2G/3G号段 (CDMA2000 网络) 133, 153, 180, 181, 189
- 4G号段 177
- 卫星手机 1349
联通
- 2G号段(GSM 网络)130, 131, 132, 155, 156
- 3G上网卡 145
- 3G号段 (WCDMA 网络) 185, 186
- 4G号段 176, 185[1]
移动
- 2G号段 (GSM 网络) 134x (0-8), 135, 136, 137, 138, 139, 150, 151, 152, 158, 159, 182, 183, 184
- 3G号段 (TD-SCDMA 网络) 有 157, 187, 188
- 3G上网卡 147
- 4G号段 178
Kind: inner method of zh/isPhoneNumber
Param | Type | Description |
---|---|---|
value | string |
a string |
格式说明
- 区号 3-4 位, 号码 7-8 位
- 可以有分机号, 分机号为 3-4 位
- 示例: "0775-85333333-123"
Kind: inner method of zh/isPhoneNumber
Param | Type | Description |
---|---|---|
value | string |
a string |
格式说明
- 大陆地区邮编为 0-8 开头的 6 位数字
- 港澳台地区为 999 开头的 6 位数字
Kind: inner method of zh/isPostcode
Param | Type | Description |
---|---|---|
value | string |
a string |