String,Check,Currency,Mask

CurrencyService

You can override to set the startingUnit, megaUnit, precision, ingoreZeroPrecision through Global Configuration.

format

Format a number with commas as thousands separators.

10000 => `10,000`
10000.567 => `10,000.57`

Use anguar currency pipe parse when is set, pls refer to document.

mega

Large number format filter.

1000 => { value: '1', unit: 'K', unitI18n: '千' }
12456 => { value: '12.46', unit: 'K', unitI18n: '千' }

cny

Converted into RMB notation.

1 => 壹元整
1.34 => 壹元叁角肆分

format

String formatting.

format('this is ${name}', { name: 'asdf' })
// output: this is asdf
format('this is ${user.name}', { user: { name: 'asdf' } }, true)
// output: this is asdf

formatMask

Format mask.

CharacterDescription
0Any numbers, if the character at that position does not match, the default is 0 to fill
9Any numbers
#Any letter
UConvert to uppercase
LConvert to lowercase
*Convert to * character
formatMask('123', '(###)') => (123)
formatMask('15900000000', '999****9999') => 159****0000
formatMask('aBc', 'UUU') => ABC
formatMask('ABc', 'LLL') => abc

Or custom Token:

const option: FormatMaskOption = {
  mask: 'CC999',
  tokens: { C: { pattern: /.*/, transform: char => (char === '你' ? 'N' : 'H') } }
}
formatMask('你好123', option) => NH123

REGEX

A set of common regular expressions. You can also get their regular string format through REGEX_STR, and cooperate with new RegExp to complete some additional processing.

num

Wheter is number.

int

Wheter is integer.

decimal

Wheter is decimal.

idCard

Wheter is People's Republic of China identity card.

isMobile

Wheter is mobile (China).

isUrl

Wheter is url address.

isIp

Wheter is IP address (Support v4, v6).

isColor

Wheter is color.

isChinese

Wheter is chi