Replace a regex in one file with the contents of another.
Switch branches/tags
greenkeeper-babel-eslint-7.0.0 greenkeeper-babel-eslint-7.1.0 greenkeeper-babel-eslint-7.1.1 greenkeeper-babel-eslint-7.2.0 greenkeeper-babel-eslint-7.2.1 greenkeeper-babel-eslint-7.2.2 greenkeeper-babel-eslint-7.2.3 greenkeeper-codeclimate-test-reporter-0.4.0 greenkeeper-codeclimate-test-reporter-0.4.1 greenkeeper-eslint-3.9.0 greenkeeper-eslint-3.9.1 greenkeeper-eslint-config-airbnb-10.0.0 greenkeeper-eslint-config-airbnb-10.0.1 greenkeeper-eslint-config-airbnb-11.0.0 greenkeeper-eslint-config-airbnb-11.1.0 greenkeeper-eslint-config-airbnb-11.2.0 greenkeeper-eslint-config-airbnb-12.0.0 greenkeeper-eslint-config-airbnb-13.0.0 greenkeeper-eslint-config-airbnb-14.0.0 greenkeeper-eslint-config-airbnb-14.1.0 greenkeeper-eslint-config-airbnb-15.0.0 greenkeeper-eslint-config-airbnb-15.0.1 greenkeeper-eslint-plugin-import-1.9.2 greenkeeper-eslint-plugin-import-1.10.0 greenkeeper-eslint-plugin-import-1.10.1 greenkeeper-eslint-plugin-import-1.10.2 greenkeeper-eslint-plugin-import-1.10.3 greenkeeper-eslint-plugin-import-1.11.0 greenkeeper-eslint-plugin-import-1.11.1 greenkeeper-eslint-plugin-import-1.12.0 greenkeeper-eslint-plugin-import-1.13.0 greenkeeper-eslint-plugin-import-1.14.0 greenkeeper-eslint-plugin-import-1.15.0 greenkeeper-eslint-plugin-import-1.16.0 greenkeeper-eslint-plugin-import-2.0.0 greenkeeper-eslint-plugin-import-2.0.1 greenkeeper-eslint-plugin-import-2.1.0 greenkeeper-eslint-plugin-import-2.2.0 greenkeeper-eslint-plugin-import-2.3.0 greenkeeper-fs-jetpack-0.10.0 greenkeeper-fs-jetpack-0.10.1 greenkeeper-fs-jetpack-0.10.2 greenkeeper-fs-jetpack-0.10.3 greenkeeper-fs-jetpack-0.10.4 greenkeeper-fs-jetpack-0.10.5 greenkeeper-fs-jetpack-0.11.0 greenkeeper-fs-jetpack-0.12.0 greenkeeper-fs-jetpack-0.13.0 greenkeeper-fs-jetpack-0.13.1 greenkeeper-fs-jetpack-0.13.2 greenkeeper-fs-jetpack-0.13.3 greenkeeper-fs-jetpack-1.0.0 greenkeeper-ghooks-2.0.0 greenkeeper-npm-run-all-3.0.0 greenkeeper-npm-run-all-3.1.0 greenkeeper-npm-run-all-3.1.2 greenkeeper-npm-run-all-4.0.0 greenkeeper-npm-run-all-4.0.1 greenkeeper-npm-run-all-4.0.2 master
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.editorconfig
.eslintrc
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
package.json

README.md

Travis Test Coverage Code Climate

rereplace

rereplace simply takes a regex with a capture group, reads a file, and replaces the capture group with the contents of another file.

Origin

I switched an entire build over to using cli tools and npm scripts. I ran into a problem with an svg spritesheet generating library – I needed to inject the output into a template. I slammed my head against the wall with sed and awk for a while, but finally decided to write a simple module that will do exactly what I ask using JS-compatible regexes.

Installation

npm i -S rereplace

Use

CLI

rereplace '/your-regex-as-a-string/' infile.html outfile.txt

as a module

import rereplace from 'rereplace';

rereplace('/your-regex-as-a-string/', './path/to/infile.html',
'./path/to/outfile.txt');