Skip to content

Commit

Permalink
feat: Added more flavour support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anadian committed Sep 24, 2021
1 parent 6d91f9d commit be55ac0
Show file tree
Hide file tree
Showing 3 changed files with 1,239 additions and 71 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![License](https://img.shields.io/github/license/Anadian/regex-translator)](https://github.com/Anadian/regex-translator/LICENSE)
[![npm](https://img.shields.io/npm/v/regex-translator)](https://www.npmjs.com/package/regex-translator)
[![Travis (.org)](https://img.shields.io/travis/Anadian/regex-translator)](https://travis-ci.org/Anadian/regex-translator)
[![Coveralls github](https://img.shields.io/coveralls/github/Anadian/regex-translator)](https://coveralls.io/github/Anadian/regex-translator?branch=master<Paste>)
[![Coveralls github](https://img.shields.io/coveralls/github/Anadian/regex-translator)](https://coveralls.io/github/Anadian/regex-translator?branch=master)
![David](https://img.shields.io/david/Anadian/regex-translator)

> Convert a Regular Expression from one flavour to another.
Expand All @@ -18,6 +18,20 @@
- [Contributing](#Contributing)
- [License](#License)
# Background
I love [regex](https://en.wikipedia.org/wiki/Regular_expression)! It's extremely useful and I practice it nigh religiously but there's a catch: regular expressions have never had a singular, definitive standard that has really taken off and, as a result, each regex engine has its own slightly different variation on the core syntax. For example: PCRE has the most features and is the flavour most commonly used in user-facing applications but I primarily program in Javascript nowadays which has its own standard for regex (ECMA) and I use Vim as my text editor which uses its own hyper-idiomatic version of regular expressions! Eventually, I got tired of the headaches from manually converting between regex flavours so I created this, a NodeJS package and CLI application for converting between regex flavours with relative ease. `regex-translator` lays a simple, data-driven foundation which can be expanded upon to one day be able to perfectly interpolate between all regex flavours. In its current state, it's not perfect but it has proved to be effective for my needs, converting between some of the more major regex flavours.
## Supported Regex Flavours
ID | "Standard" | Uses
--- | --- | ---
`basic` | [Posix.2 "Basic Regular Expression" (BRE)](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03) | `grep`, `ed` and C (`<regex.h>`)
`extended` | [Posix.2 "Extended Regular Expressions" (ERE)](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04) | `egrep` and C (`<regex.h>`)
`pcre` | [Perl Compatible Regular Expressions (PCRE)](https://www.pcre.org/) | PCRE library, Perl, PHP, and many others.
`vim` | [Vim Pattern](https://vimhelp.org/pattern.txt.html) | Vim
`ecma` | [ECMAscript RegExp](https://262.ecma-international.org/12.0/#sec-regexp-regular-expression-objects) | Javascript, Web Browsers, ~Java
`re2` | [RE2](https://github.com/google/re2) | GoLang, ~Python

'Standard' is in quotes there because regular expressions are quite tenuously specified in the best of cases: POSIX's regular expression standard is quite vague and largely obsolete and much of the format specification for other regex flavours comes from high-level end-user-targeted documentation.

`regex-translator` in no way purports to be fast or memory efficient but it does strive to be useful, simple, and transparent in its operation.
# Install
`npm install regex-translator`
to install it to a local package or
Expand Down

0 comments on commit be55ac0

Please sign in to comment.