# Class StringUtil

字符串工具

#### Hierarchy

- StringUtil

- Defined in assets/core/utils/StringUtil.ts:2

#####
Index

### Constructors

constructor

### Methods

IsEmpty
format
guid
numberToTenThousand
numberToThousand
numberTotPermil
stringLen
stringToArray1
stringToArray2
stringToArray3
stringToArray4
sub
substitute

## Constructors

### constructor

- new StringUtil(): StringUtil

- #### Returns StringUtil

## Methods

### `Static` IsEmpty

- IsEmpty(str: string): boolean

- 是否为空

  #### Parameters

  - ##### str: string

  #### Returns boolean

  - Defined in assets/core/utils/StringUtil.ts:176

### `Static` format

- format(date: Date, fmt: string): string

- 时间格式化

  #### Parameters

  - ##### date: Date

    时间对象

  - ##### fmt: string

    格式化字符(yyyy-MM-dd hh:mm:ss S)

  #### Returns string

  - Defined in assets/core/utils/StringUtil.ts:69

### `Static` guid

- guid(): string

- 获取一个唯一标识的字符串

  #### Returns string

  - Defined in assets/core/utils/StringUtil.ts:4

### `Static` numberToTenThousand

- numberToTenThousand(value: number, fixed?: number): string

- 转中文单位计数

  ### Example

      12345 = 1.23万

  #### Parameters

  - ##### value: number

    数字

  - ##### fixed: number = 2

    保留小数位数

  #### Returns string

  - Defined in assets/core/utils/StringUtil.ts:52

### `Static` numberToThousand

- numberToThousand(value: number, fixed?: number): string

- 转英文单位计数

  ### Example

      12345 = 12.35K

  #### Parameters

  - ##### value: number

    数字

  - ##### fixed: number = 2

    保留小数位数

  #### Returns string

  - Defined in assets/core/utils/StringUtil.ts:32

### `Static` numberTotPermil

- numberTotPermil(value: number): string

- 转美式计数字符串

  ### Example

      123456789 = 123,456,789

  #### Parameters

  - ##### value: number

    数字

  #### Returns string

  - Defined in assets/core/utils/StringUtil.ts:21

### `Static` stringLen

- stringLen(str: string): number

- 计算字符串长度，中文算两个字节

  #### Parameters

  - ##### str: string

    字符串

  #### Returns number

  - Defined in assets/core/utils/StringUtil.ts:160

### `Static` stringToArray1

- stringToArray1(str: string): string[]

- "," 分割字符串成数组

  #### Parameters

  - ##### str: string

    字符串

  #### Returns string[]

  - Defined in assets/core/utils/StringUtil.ts:94

### `Static` stringToArray2

- stringToArray2(str: string): string[]

- "|" 分割字符串成数组

  #### Parameters

  - ##### str: string

    字符串

  #### Returns string[]

  - Defined in assets/core/utils/StringUtil.ts:105

### `Static` stringToArray3

- stringToArray3(str: string): string[]

- ":" 分割字符串成数组

  #### Parameters

  - ##### str: string

    字符串

  #### Returns string[]

  - Defined in assets/core/utils/StringUtil.ts:116

### `Static` stringToArray4

- stringToArray4(str: string): string[]

- ";" 分割字符串成数组

  #### Parameters

  - ##### str: string

    字符串

  #### Returns string[]

  - Defined in assets/core/utils/StringUtil.ts:127

### `Static` sub

- sub(str: string, n: number, showdot?: boolean): string

- 字符串截取

  #### Parameters

  - ##### str: string

    字符串

  - ##### n: number

    截取长度

  - ##### showdot: boolean = false

    是否把截取的部分用省略号代替

  #### Returns string

  - Defined in assets/core/utils/StringUtil.ts:140

### `Static` substitute

- substitute(str: string, ...rest: any[]): string

- 参数替换

  ### Example

      var str:string = "here is some info '{0}' and {1}";
      StringUtil.substitute(str, 15.4, true);

      "here is some info '15.4' and true"

  #### Parameters

  - ##### str: string

  - ##### `Rest` ...rest: any[]

  #### Returns string

  - Defined in assets/core/utils/StringUtil.ts:195

Generated using TypeDoc