Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okofish/node-bulkregex
CLI for applying lots of regexes to a text file
https://github.com/okofish/node-bulkregex
Last synced: 16 days ago
JSON representation
CLI for applying lots of regexes to a text file
- Host: GitHub
- URL: https://github.com/okofish/node-bulkregex
- Owner: okofish
- Created: 2015-08-10T20:48:28.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-21T01:51:04.000Z (about 9 years ago)
- Last Synced: 2024-04-21T13:51:48.429Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-bulkregex
CLI for easy application of lots of regexes to a text file
*Like sed/ed for people who can't be bothered to learn sed/ed*## Usage
node replace.js [switches]
-i/--input: Input file to execute regexps on. Defaults to stdin.
-o/--output: File to save result to. Defaults to stdout.The replacement file is a JSON file that looks something like this:
```
[{
"from": "new study",
"to": "tumblr post"
}, {
"from": "wheee*!?",
"to": "whee!"
}, {
"from": "space",
"to": "SPAAACE",
"flags": "gi"
}, {
"from": "smartphone",
"to": "pokédex"
}]
```### Example
Included in the repo is an xkcd-themed replacement file and the full text of the Wikipedia article on computer keyboards. Try it out with this:```
node replace.js xkcd1031.json -i keyboard.txt -o leopard.txt
```## Performance
Speedy performance is an important part of any bulk replacement program. I test this one using `benchmark.sh`, included in the repo. On my MacBook Air, it executes in around 300 ms (wall clock time.)