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.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more