DEV Community

Cover image for Improve your content searching/filtering workflow productivity with regexp-it-cli
akgondber
akgondber

Posted on • Edited on

1

Improve your content searching/filtering workflow productivity with regexp-it-cli

Involve regular expressions to solve different kind of tasks regarding text content

Let me introduce a nodejs library called regexp-it-cli - cli tool that provides content searching/filtering functionality by regular expressions. It has plenty of features, some of them will be highlighted in this post.

I am going to demonstrate some use cases where this tool would be applicable.

Regexp playground

You can experiment with regular expression by passing some content as a source and executing your trial regular over it. For example, display only matched parts for specified regexp:

Show some content in slide mode

Have you ever wanted a find functionality without dealing with manually movement handling to the next match but automatically see the next matches with some interval? Slide mode to the rescue! Use the --slide-mode option optionally providing also --slide-delay specifying a delay in seconds you'd like:

Filtering content between sections

You can use regexp in a source only after/before specified --after-regexp and --before-regexp:

Image description

Displaying first and last match

Display only first/last match by providing the --only-first-match / --only-last-match flag

$ regexp-it-cli --url "https://raw.githubusercontent.com/inversify/InversifyJS/master/src/container/container.ts" --regexp "throw.*" -m -q --only-first-match
Enter fullscreen mode Exit fullscreen mode

Using predefined patterns

Use predefined patterns instead of specifying --regexp yourself by using --regexp-pattern option.

regexp-it-cli --file "samples/misc.txt" --regexp-pattern "urlLine" -e -m -q

Specify starting/ending line from a source to be used as a content

Apply filter to content that is going to be used a source for a regular expression by using the --starting-line-number, --ending-line-number options.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay