Options
All
  • Public
  • Public/Protected
  • All
Menu

Module string/replace

Index

References

Functions

References

Renames and re-exports replace

Functions

  • replace(pattern: Pattern, replacement: string, str: string): string
  • replace(pattern: Pattern, replacement: string): (str: string) => string
  • replace(pattern: Pattern): CurriedFunction2<string, string, string>
  • Replace a substring or regex match in a string with a replacement.

    example
     replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
    replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'

    // Use the "g" (global) flag to replace all occurrences:
    replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'

    Parameters

    • pattern: Pattern

      A regular expression or a substring to match.

    • replacement: string

      The string to replace the matches with.

    • str: string

      The String to do the search and replacement in.

    Returns string

    The result.

  • Replace a substring or regex match in a string with a replacement.

    example
     replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
    replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'

    // Use the "g" (global) flag to replace all occurrences:
    replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'

    Parameters

    • pattern: Pattern

      A regular expression or a substring to match.

    • replacement: string

      The string to replace the matches with.

    Returns (str: string) => string

    The result.

      • (str: string): string
      • Parameters

        • str: string

        Returns string

  • Replace a substring or regex match in a string with a replacement.

    example
     replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
    replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'

    // Use the "g" (global) flag to replace all occurrences:
    replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'

    Parameters

    • pattern: Pattern

      A regular expression or a substring to match.

    Returns CurriedFunction2<string, string, string>

    The result.

Generated using TypeDoc