replace

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
923 B
Replace a substring or regex match in a string with a replacement.
1 contributor
Install replace as a package?
Copied
npm i @bit/justin-capalbo.ramda.replace
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
replace (
pattern:(RegExp | String),
replacement:String,
str:String
) : String

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

The first two parameters correspond to the parameters of the String.prototype.replace() function, so the second parameter can also be a function.

Example
R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
     R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'

     // Use the "g" (global) flag to replace all occurrences:
     R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'
Arguments
pattern: (RegExp | String)

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.

Help and resources