Function patternEdgeAssertions

  • This transformer will only touch assertion that assert characters beyond the edge of the pattern.

    E.g. in /(?<!\w)(?!\d)\w+(?=\s*<)/ only (?<!\w) and (?=\s*<) are pattern edge assertions.

    The transformer can inline non-negated assertions (e.g. /(?<!\w)(?!\d)\w+(?=\s*<)/ => /(?<!\w)(?!\d)\w+\s*</) and/or remove them (e.g. /(?<!\w)(?!\d)\w+\s*</ => /(?!\d)\w+\s*</).

    If both inlining and removal are active, then inlining will be done first, e.g. a(?=\w)(?!\d) => a(?!\d)\w, which may prevent some removal. Some assertions will not be removed because another may be inlined later. E.g. the (?!\d) in (?=\w)a?(?!\d) will not be removed because the pattern may be transformed to (?:a|(?=\w))(?!\d) => a(?!\d)|(?=\w)(?!\d) which can be inlined to a(?!\d)|(?!\d)\w and transformed to a(?!\d)|[A-Z_a-z].

    If neither inlining nor removal are active, then this transformer won't do anything.

    Parameters

    Returns Transformer