Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PowerSplit

Library entry point. Expose static methods for different operations.

Hierarchy

  • PowerSplit

Index

Methods

Static cutAt

  • Cut the original string into two parts: what's before and what's after the specified token. You can specify where the token will be included.

    Parameters

    • cutPoint: TokenWithIndexes

      The point where to cut the string.

    • Default value tokenInAfter: boolean = true

      If set to true (default) then the specified token is placed in the "after" part.

    Returns string[]

    A two element array, the first element is the "before" part, the second the "after".

Static split

  • split(input: string, re: RegExp, limit?: undefined | number, limitMode?: LimitMode): string[]
  • Like calling splitWithIndexes() but returns raw tokens instead of objects.

    Parameters

    • input: string

      The string to work on.

    • re: RegExp

      The regular expression to parse with.

    • Optional limit: undefined | number

      Maxium number of elements to return.

    • Default value limitMode: LimitMode = LimitMode.STOP_AT

      How the limit argument should be applied.

    Returns string[]

    The parsed tokens.

Static splitWithIndexes

  • Performs a split using a regular expression returing tokens with index data.

    Parameters

    • input: string

      The string to work on.

    • re: RegExp

      The regular expression to parse with.

    • Optional limit: undefined | number

      Maxium number of elements to return.

    • Default value limitMode: LimitMode = LimitMode.STOP_AT

      How the limit argument should be applied.

    Returns TokenWithIndexes[]

    An array of tokens splitted from the input string. Each item contains start and end indexes.

Static substring

  • Returns a substring of the original string starting from token start. If end is supplied then the substring ends after that token. If start is undefined then "" is returned, If end is not given then the remaining string is returned.

    This method (like others) assumes that start and end refer to the same string. If it's not the case then unpredicatable results will occur.

    Parameters

    • start: TokenWithIndexes

      The token to start from (inclusive).

    • Optional end: TokenWithIndexes

      The token to stop at (inclusive). If not given all the remaining string is returned.

    Returns string

    The original string section starting at the token at index

Generated using TypeDoc