Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

laktak/textgrep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

textgrep

NPM version

Usage

usage: textgrep [OPTIONS] PATTERN [FORMAT] [FLAGS]

  textgrep can be used to extract regex matches from a string.

  Unless -f is specified the text will be read from stdin.

  PATTERN
  Specifies the regex you wish to match and capture.
  Follows the JavaScript RegExp syntax, see
  https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
  Use [^]*? to match any character over multiple lines.

  FORMAT
  Specifies the format to output the captured groups.
  You can use {#} to reference a group where # is the index.
  Escapes (like \n, \t) are allowed.
  Default: {1}\n

  FLAGS
  Specifies the regex flags (see MDN).
  Default: gm

  OPTIONS
  -f=FILE:     will read the text from the given file.
  --:          stops evaluation of options
               (allows the PATTERN to start with -)
  --?|--help:  shows this help screen.

Sample:
  man ls | col -bx | textgrep '^     -(\w+)\s+([^]*?)^$' '   -{1} means: {2}\n\n'

Install from npm

npm install textgrep -g

API

see lib/textgrep.js

About

Extract multiline regex matches from text

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published