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

https://github.com/branneman/jsgrep-cli

An alternative to grep which uses JavaScript's Regex, supports a match and a match-and-replace
https://github.com/branneman/jsgrep-cli

cli grep javascript js pcre regex tool

Last synced: about 1 year ago
JSON representation

An alternative to grep which uses JavaScript's Regex, supports a match and a match-and-replace

Awesome Lists containing this project

README

          

# jsgrep-cli

[![Build Status](https://travis-ci.org/branneman/jsgrep-cli.svg?branch=master)](https://travis-ci.org/branneman/jsgrep-cli)
[![Known Vulnerabilities](https://snyk.io/test/github/branneman/jsgrep-cli/badge.svg)](https://snyk.io/test/github/branneman/jsgrep-cli)

An alternative to grep which uses JavaScript's Regex, supports a match and a match-and-replace

## Installation

```
npm i jsgrep-cli -g
```

## Example

Match input from stdin, return any matching line:

```
ls -al ~ | jsgrep " \.[a-z]+rc$"
```

Match and replace lines from stdin. Capturing groups are exposed as `$1`, `$2`... variables (1-indexed), and must probably be escaped to prevent being interpreted by your shell:

```
ls -al ~ | jsgrep ".+ (\.[a-z]+rc$)" "\$1"
```

Passing flags (default `i`):

```
ls -al ~ | jsgrep " \.[a-z]+rc$" --flags iu
```