|
1 | | -# rexreplace |
2 | | -CLI regexp replacement with lookahead and backreference to matching groups in the replacement. What "sed" should have been. |
| 1 | +[](https://travis-ci.org/mathiasrw/rexreplace) |
| 2 | +[](https://www.npmjs.com/package/rexreplace) |
| 3 | + |
| 4 | +# RexReplace |
| 5 | + |
| 6 | +CLI Regexp search and replace for files using lookahead and |
| 7 | +backreference to matching groups in the replacement. Defaults to global |
| 8 | +multiline case-insensitive search. Needs Node v6 or higher. |
| 9 | + |
| 10 | +### Install |
| 11 | +```bash |
| 12 | +> npm install -g rexreplace |
| 13 | +``` |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +### Usages |
| 18 | +```bash |
| 19 | +> rexreplace searchFor replaceWith filenameA filenameB filenameC ... |
| 20 | +``` |
| 21 | + |
| 22 | +### Examples |
| 23 | +```bash |
| 24 | +> rexreplace Foo xxx myfile.md |
| 25 | + # 'foobar' in myfile.md will become 'xxxbar' |
| 26 | + |
| 27 | +> rexreplace Foo xxx myfile.md -I |
| 28 | + # 'foobar' in myfile.md will remain 'foobar' |
| 29 | + |
| 30 | +> rexreplace '(f?(o))o(.*)' '$3$1$2' myfile.md |
| 31 | + # 'foobar' in myfile.md will become 'barfoo' |
| 32 | + |
| 33 | + # Some commandline tools (bash/zsh/...) can be a bit funny with the `$` sign. Use the '-€' flag to let `€` alias a `$` in pattern and replacement |
| 34 | +> rexreplace '(f?(o))o(.*)' '€3€1€2' myfile.md -€ |
| 35 | + # 'foobar' in myfile.md will become 'barfoo' |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +``` |
| 40 | + |
| 41 | + |
| 42 | +### Options |
| 43 | + |
| 44 | +``` |
| 45 | + -v, --version Echo rexreplace version [boolean] |
| 46 | + -I, --void-ignore-case Void case insensitive search pattern. [boolean] |
| 47 | + -M, --void-multiline Void multiline search pattern. Makes ^ and $ match |
| 48 | + start/end of whole content rather than each line. |
| 49 | + [boolean] |
| 50 | + -u, --unicode Treat pattern as a sequence of unicode code points. |
| 51 | + [boolean] |
| 52 | + -e, --encoding Encoding of files. [default: "utf8"] |
| 53 | + -o, --output Output the result instead of saving to file. Will also |
| 54 | + output content even if no replacement have taken |
| 55 | + place. [boolean] |
| 56 | + -q, --quiet Only display erros (no other info) [boolean] |
| 57 | + -Q, --quiet-total Never display erros or info [boolean] |
| 58 | + -H, --halt Halt on first error [boolean] [default: false] |
| 59 | + -d, --debug Print debug info [boolean] |
| 60 | + -€, --eurodollar Replace all '€' with '$' in pattern and replace |
| 61 | + string. Usefull when your commandline (bash/zsh/...) |
| 62 | + seeks to do interesting things with '$' [boolean] |
| 63 | + -h, --help Show help [boolean] |
| 64 | +``` |
| 65 | + |
| 66 | +### Future |
| 67 | +- Handle globs |
| 68 | +- Handle piped data |
| 69 | + |
| 70 | +### inspiration |
| 71 | + |
| 72 | +.oO(_What "sed" should have been by now_) |
| 73 | + |
| 74 | +The replace-in-file npm package (but with better naming and backreferences) |
0 commit comments