Function regexScopeTree

  • Builds a regex that matches a string between two strings. Supports regex instead of string.

    Parameters

    • left: string | RegExp

      string or regex to match before

    • right: string | RegExp

      string or regex to match after

    Returns ((string, yieldOnlyRootNodes?) => Generator<RegexScopeTreeNode>)

    A generator function that takes a string and an optional boolean parameter. The generator function yields nodes of type IRegexScopeTreeNode.

    Throws

    If a match does not recognize itself as neither left nor right.

    Example

    const generator = regexScopeTree('(', ')')
    const iterable = generator('(1+((3)+(1)))+(15+(21-(521))))', true)
    console.dir([...iterable], { depth: null })

Generated using TypeDoc