Amazon Vinyl
    Preparing search index...

    Function substitute

    • Substitutes named variable references in a string.

      Example:

      substitute('{fruit}, {veg}', { fruit: 'apples', veg: 'carrots' }) // 'apples, carrots'
      

      Parameters

      • str: string

        The template string.

      • variables: Readonly<Record<string, any>>

        A record of variable names to values.

      • pattern: RegExp = DEFAULT_SUBSTITUTE_PATTERN

        A regex whose first capture group is the variable name. Defaults to {name}.

      Returns string

      IllegalArgumentError if a referenced variable is not defined.