Class StringUtil

字符串工具

Hierarchy

  • StringUtil

Constructors

Methods

  • 是否为空

    Parameters

    • str: string

    Returns boolean

  • 时间格式化

    Parameters

    • date: Date

      时间对象

    • fmt: string

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

    Returns string

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

    Returns string

  • 转中文单位计数

    Example

    12345 = 1.23
    

    Parameters

    • value: number

      数字

    • fixed: number = 2

      保留小数位数

    Returns string

  • 转英文单位计数

    Example

    12345 = 12.35K
    

    Parameters

    • value: number

      数字

    • fixed: number = 2

      保留小数位数

    Returns string

  • 转美式计数字符串

    Example

    123456789 = 123,456,789
    

    Parameters

    • value: number

      数字

    Returns string

  • 计算字符串长度,中文算两个字节

    Parameters

    • str: string

      字符串

    Returns number

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

    Parameters

    • str: string

      字符串

    Returns string[]

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

    Parameters

    • str: string

      字符串

    Returns string[]

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

    Parameters

    • str: string

      字符串

    Returns string[]

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

    Parameters

    • str: string

      字符串

    Returns string[]

  • 字符串截取

    Parameters

    • str: string

      字符串

    • n: number

      截取长度

    • showdot: boolean = false

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

    Returns 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

Generated using TypeDoc