Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Replace Operations

See original GitHub issue

Is it possible to do multiple find and replace operations with this plugin a bit like how gulp-batch-replace works?

var replacements = [
    [ 'original', 'replacement' ],
    [ 'original1', 'replacement1' ],
    [ 'original2', 'replacement2' ]
    // ...N number of replacements.

var replace = require('gulp-replace');

gulp.task('templates', function(){
    .pipe(replace(??????????))  // What do I do here?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:9
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

dougiefresh49commented, Jun 25, 2018

I was able to accomplish the multiple replaces very easily with the pseudo code from @chebum

here is a more fleshed out example:

gulp.task('inject:mock-data', () => {
  let mockData = JSON.parse(fs.readFileSync('./data.json'));

  let task = gulp.src('./dist/*.html');

  Object.keys(data).forEach((key) => {
    task = task.pipe(replace(`{{${key}}}`, data[key]));

  return task.pipe(gulp.dest('./dist'));

hope this helps

RehanSaeedcommented, Nov 15, 2015

That breaks the Gulp pipeline flow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel: find and replace multiple values at once - Ablebits
The easiest way to find and replace multiple entries in Excel is by using the SUBSTITUTE function. The formula's logic is very simple:...
Read more >
Quicker Multiple Replace Operations (Microsoft Word)
When you are specifying the number of tabs to replace, it is best to use a multiple of two. For instance, in the...
Read more >
How to replace multiple substrings of a string? - Stack Overflow
Here is a short example that should do the trick with regular expressions: import re rep = {"condition1": "", "condition2": "text"} # define...
Read more >
Python | Replace multiple characters at once - GeeksforGeeks
The replacement of one character with another is a common problem that every Python programmer would have worked with in the past.
Read more >
5 Ways to Replace Multiple Characters in String in Python
In this article, we will learn how to replace multiple characters in a string in ... Strings have many operations to be performed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found