1.0.6 • Published 1 year ago

stupex v1.0.6

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Table of Contents

Installation

Install the stupex package using npm:

npm install stupex

Summary

Stupex is a user-friendly, intuitive syntax for working with regular expressions, designed to make it easier for non-programmers and those with minimal technical skills to create, read, and understand regex patterns.

Why Stupex

  • Regular expressions can be quite powerful, but their syntax is often considered cryptic and hard to grasp, especially for beginners. The purpose of the Stupex package is to provide a more accessible alternative to regex, using a simplified and descriptive syntax.

  • Stupex expressions can be easily translated to regular expressions and vice versa using the provided functions, making it simple to integrate Stupex into your existing projects or learn regex patterns from their Stupex counterparts.

  • By using Stupex, you can harness the power of regular expressions without getting lost in their complex syntax.

Features

  • Intuitive, human-readable syntax for defining regular expressions

  • Bi-directional conversion between Stupex and regex expressions

  • Compatibility with existing JavaScript regex patterns

Usage

The Stupex package provides two main functions for converting between Stupex and regex expressions:

NorEx-to-RegEx

stupexToRegex() Converts a Stupex expression to a regex pattern.

RegEx-to-NorEx

regexToStupex() Converts a regex pattern to a Stupex expression.

These functions can be used to seamlessly integrate Stupex into your existing codebase and simplify the process of working with regular expressions.

Available Expressions

For a complete list of available Stupex expressions and their corresponding regex patterns, please refer to the Stupex Expressions Table.

Examples

Search for http:// or https://:

# Stupex

// Syntax #1

line-start:
  "http"
  optional "s"
  "://"


// Syntax #2

line-start:
  "http"
  optional("s")
  "://"


// Syntax #3

line-start("http" optional("s") "://")
# Regex

^http(?:s)?://

Search for hello world:

# Stupex

// Syntax #1

"hello"
any:
  whitespace
  non-whitespace
"world"


// Syntax #2

"hello"
any whitespace non-whitespace
"world"


// Syntax #3
"hello" any(whitespace non-whitespace) "world"
# Regex

hello[\s\S]*?world

Table of Expressions

Regex ExpressionStupex ExpressionDescription
.(char)Any character
^expstarts-with(exp)Starts with expression
exp$ends-with(exp)Ends with expression
^exp$is-within(exp)Is within expression
exp*optional(exp)Zero or more repetitions
exp+at-least-once(exp)One or more repetitions
exp?once-at-most(exp)Zero or one repetition
{n}repeat-n-times(exp)Repeat n times
{n,}repeat-n-or-more(exp)Repeat n or more times
{n,m}repeat-n-to-m(exp)Repeat n to m times
[chars]with(chars)Any character in set
[^chars]without(chars)Any character not in set
exp\|alteither-or(exp,alt)Either expression or alternative
\(exp\)group(exp)Group expression
\\escape-symbolEscape symbol
\d(digit)Digit character
\D(non-digit)Non-digit character
\w(word-char)Word character
\W(non-word-char)Non-word character
\s(whitespace)Whitespace character
\S(non-whitespace)Non-whitespace character
\bexpword(exp)Word boundary expression
\Bexpnon-word(exp)Non-word boundary expression
(?=exp)will-occur(exp)Positive lookahead
(?!exp)will-not-occur(exp)Negative lookahead
(?<=exp)has-occurred(exp)Positive lookbehind
(?<!exp)has-not-occurred(exp)Negative lookbehind
(?:exp)non-capture-group(exp)Non-capturing group
(?=exp-1)(?=exp-2)...(?=exp-n)all-of(exp-1, ..., exp-n)All expressions occur
exp-1\|exp-2\|...\|exp-none-of(exp-1, ..., exp-n)One of the expressions occurs
(?=exp-1) (?=exp-2) (?!(?=exp-1) (?=exp-2)some-of(exp-1, ..., exp-n)Some of the expressions occur
exp-1(?=.*exp-2)(?=.*exp-3)...all-of-by-this-order(exp-1, ..., exp-n)All expressions occur in order
Custom implementationjs-symbol(exp)Any JS symbol with name returned from expression
Custom implementationjs-class(exp)Any JS class with name returned from expression
Custom implementationjs-function(exp)Any JS function with name returned from expression
Custom implementationjs-interface(exp)Any JS interface with name returned from expression
Custom implementationjs-arg(exp)Any JS argument with a name described as expression
  • Additional expressions available, see package documentation for details.

Contributing

We welcome contributions to improve and expand the Stupex package. If you have ideas for new expressions or improvements to the syntax, please feel free to submit a pull request or open an issue on the project's GitHub repository.

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago