News

Introducing ReX.js v1.0.0 a companion library for RegEx written in TypeScript

2 min read

ReX.js is a helper library written in TypeScript for writing Regular Expressions. Yesterday, ReX.js v1.0.0, the first major version was released. Being written in TypeScript, it provides great autocompletion and development experience across various modern code editors. One of the main advantages of using ReX.js is its ability to document every line of code without hassles.

Anatomy of  ReX.js v1.0.0

ReX.js is structured as namespace consisting of the following modules:

  • Matcher: It is the class used to construct and use matching expressions.
  • Replacer: The Replacer class is used to construct and use replacement expressions.
  • Operation: This class represents a basic operation that is applied to expressions constructors.
  • Parser: The parser class used to parse and execute Regexps. It is used by Matcher and implements polyfills for named groups and partially for look behinds.
  • ReXer: It is used to construct Regexps. The Matcher and Replacer classes inherit from ReXer.

The GitHub page says that the Matcher and Replacer classes will be used more likely by developers. The other classes would more likely be used for extendability and advanced use cases.

Advanced use of ReX.js v1.0.0

Beyond basic Regex operations, ReX.js also provides options for extending its functionality.

Operations and channels

Every method used in ReX.js is just adding a new Operation to ReXer. An Operation can then be stringified using its own stringify method.

A concept of channels is introduced to construct linear Regexps from nested function expressions. A channel is simply an array of Operations. The channels themselves are stored as an array in ReXer.

Snippets

Snippets are available if you want to reuse any kind of Operation configuration. Snippets provide an option to assign the given config to a name for later reuse.

Methods and extensions

Methods are ways to reuse and apply custom operations while extensions are just arrays of methods.

Installing ReX.js v1.0.0

ReX.js is available on NPM as a package. You can include it in your current project by using:

npm install @areknawo/rex

If you’re using Yarn, then use the following command:

yarn add @areknawo/rex

For more details and documentation, visit the ReX.js GitHub page.

Read next

Manipulating text data using Python Regular Expressions (regex)

Introducing Howler.js, Javascript audio library with full cross-browser support

low.js, Node.js port for embedded systems

Prasad Ramesh

Data science enthusiast. Cycling, music, food, movies. Likes FPS and strategy games.

Share
Published by
Prasad Ramesh

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago