Skip to content

Latest commit

 

History

History
275 lines (224 loc) · 16 KB

comparison.md

File metadata and controls

275 lines (224 loc) · 16 KB
title description excerpt date lastmod draft images menu weight toc
Comparison with other projects
See how Pomsky compares to similar projects
2022-07-10 16:21:58 +0000
2023-03-21 20:29:00 +0000
false
docs
parent
appendix
10001
true

This wiki has a list of projects with similar goals to Pomsky. Here's a list of the most popular projects:

{{< alert icon="⚠️" text="Disclaimer that as the maintainer of Pomsky, I am obviously biased. If you find any incorrect or misleading information, please open an issue." />}}

Project Types GitHub
Melody Transpiled {{}}
Pomsky Transpiled {{}}
Egg Expressions Transpiled
App: Oil shell
Rx Expressions Transpiled
App: Emacs
Raku Grammars App: Raku
Rosie App: Rosie
SRL DSL: PHP {{}}
Super Expressive DSL: JS {{}}
Verbal Expressions DSL: JS {{}}
Swift RegexBuilder DSL: Swift

Since this content is likely to get out of date, I encourage you to update it.

Types

Transpiled

These languages are transpiled to "normal" regular expressions and can therefore be used anywhere. They usually have command-line interface to compile expressions.

Application specific

Some regex languages are specific to a certain application or programming language. For example, Raku grammars can only be used in Raku; egg expressions are transpiled, but they are only available in the Oil shell.

DSLs

DSLs (domain-specific languages) are languages that are embedded in another language using the host language's syntax. For example, Verbal Expressions uses JavaScript methods:

const tester = VerEx()
  .startOfLine()
  .then('http')
  .maybe('s')
  .then('://')
  .maybe('www.')
  .anythingBut(' ')
  .endOfLine()

This page currently only discusses transpiled languages, but I welcome contributions.

Compatibility

Let's see what Regex flavors are supported by transpiled languages.

Flavor Melody Pomsky Egg Expr. Rx Expr.
ERE
ECMAScript
PCRE *
.NET *
Java *
Ruby *
Python
Rust

*Melody can only emit ECMAScript regexes, but they also happen to be compatible with several other flavors.

Explanation of the flavors

  • ERE (extended regular expressions) are used by tools such as GNU grep and awk. Because ERE supports only the most basic features, it is mostly forward compatible with other regex flavors.

  • ECMAScript is the syntax used in JavaScript and related languages (TypeScript, Elm, Dart, etc.) that are compiled to JS.

  • PCRE (an acronym for "Perl compatible regular expression") is the syntax used by the PCRE2 regex engine, which is the default in at least Crystal, Delphi, Elixir, Erlang, Hack, Julia, PHP, R and Vala. It's also a popular choice in other languages like C and C++ and is used in many applications such as the Apache server, nginx, MariaDB, MongoDB, and optionally in GNU grep.

  • .NET refers to the Regex class in .NET languages such as C# and F#.

  • Java refers to the Pattern class in Java's standard library. Equivalent to Kotlin's and Scala's regular expressions.

  • Ruby refers to built-in regular expressions in Ruby.

  • Python refers to Pythons re module. Note that Python 3 is required for good Unicode support.

  • Rust refers to Rust's popular regex crate (used by ripgrep)

Many more flavors exist, which are not (or only partially) supported by Pomsky and other languages.

Features

Let's see what Regex features are supported by languages that are transpiled to regular expressions.

Basic regex features

Feature Melody Pomsky Egg Expr. Rx Expr.
Greedy repetition
Lazy repetition
Dot
Character escape
Character class
Anchor
Word boundary
Negated word boundary
Character range partly*
Character set
Negated character set partly*
Capturing group
Alternation
POSIX class
Non-capturing group

*Character ranges and negated sets in Melody only support ASCII letters, digits and a few special characters.

Advanced features

Feature Melody Pomsky Egg Expr. Rx Expr.
Variable/macro
Line comment
Block comment
Code point
Lookaround
Named capturing group
Backreference
Named backreference
Relative backreference
Unicode category
Unicode script/block partly
Other Unicode property
Any code point partly* partly* partly*
Any grapheme
Atomic group
Character set intersection
Character set subtraction
Possessive quantifier
Conditional
Recursion
Modifier
Inline regex
Optimization some**

Note that Melody and Pomsky support inline regexes. Because of this, all Regex features are technically supported in Melody and Pomsky, but using inline regexes may be less ergonomic and more dangerous to use than properly supported features.

*All languages can match a code point with the dot, if multiline mode is enabled in the regex engine.

**Pomsky can currently optimize repetitions, remove redundant or empty groups and deduplicate code points in character sets. More optimizations are planned.

Tooling

Tool Melody Pomsky Egg Expr. Rx Expr.
CLI
REPL
Online playground
VSCode extension
IntelliJ extension
JavaScript bunder Babel Vite,
Rollup,
ESBuild,
Webpack
Rust macro
Linter
Formatter

Language integrations

Packages

Tool Melody Pomsky
Homebrew
AUR
Nix
GitHub release binary (Apple)
GitHub release binary (Windows)
GitHub release binary (Linux)
Node module
Python module

IDE features

Feature Melody Pomsky
Syntax highlighting
Error highlighting
Code folding 1 1
Auto indentation
Snippets
Matching brackets and quotes 2
Keyword autocomplete 2
Variable autocomplete 3
Backreference autocomplete
Character class autocomplete
Unicode property autocomplete
Hover tooltips
Apply suggestions
Share link (playground)

1 indentation based
2 works in playground VSCode, but not in the playground
3 does not take scopes into account


Found a mistake? Please fix it on GitHub.