Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

replace.js 754B

1234567891011121314151617181920212223242526272829
  1. var toString = require('./toString');
  2. /**
  3. * Replaces matches for `pattern` in `string` with `replacement`.
  4. *
  5. * **Note:** This method is based on
  6. * [`String#replace`](https://mdn.io/String/replace).
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 4.0.0
  11. * @category String
  12. * @param {string} [string=''] The string to modify.
  13. * @param {RegExp|string} pattern The pattern to replace.
  14. * @param {Function|string} replacement The match replacement.
  15. * @returns {string} Returns the modified string.
  16. * @example
  17. *
  18. * _.replace('Hi Fred', 'Fred', 'Barney');
  19. * // => 'Hi Barney'
  20. */
  21. function replace() {
  22. var args = arguments,
  23. string = toString(args[0]);
  24. return args.length < 3 ? string : string.replace(args[1], args[2]);
  25. }
  26. module.exports = replace;