Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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.)