mfix22 / Rexrex
Licence: mit
π¦ Composable JavaScript regular expressions
Stars: β 34
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Rexrex
Rex
Your RegEx companion.
Stars: β 283 (+732.35%)
Mutual labels: functional, regex, regular-expression
Functional Programming Learning Path
A Learning Path for Functional Programming
Stars: β 582 (+1611.76%)
Mutual labels: functional-programming, functional
Pampy.js
Pampy.js: Pattern Matching for JavaScript
Stars: β 544 (+1500%)
Mutual labels: functional-programming, functional
Fkit
A functional programming toolkit for JavaScript.
Stars: β 588 (+1629.41%)
Mutual labels: functional-programming, functional
Regulex
π§ Regular Expression Excited!
Stars: β 4,877 (+14244.12%)
Mutual labels: regex, regular-expression
Onigmo
Onigmo is a regular expressions library forked from Oniguruma.
Stars: β 536 (+1476.47%)
Mutual labels: regex, regular-expression
Immutable Tuple
Immutable finite list objects with constant-time equality testing (===) and no memory leaks.
Stars: β 29 (-14.71%)
Mutual labels: functional-programming, functional
Yalinqo
Yet Another LINQ to Objects for PHP [Simplified BSD]
Stars: β 400 (+1076.47%)
Mutual labels: functional-programming, functional
Commonregex
π« A collection of common regular expressions for Go
Stars: β 733 (+2055.88%)
Mutual labels: regex, regular-expression
Kaur
A bunch of helper functions to ease the development of your applications.
Stars: β 17 (-50%)
Mutual labels: functional-programming, functional
Shallow Clone
Make a shallow clone of an object, array or primitive.
Stars: β 23 (-32.35%)
Mutual labels: regex, regular-expression
Hof
Higher-order functions for c++
Stars: β 467 (+1273.53%)
Mutual labels: functional-programming, functional
Chinamobilephonenumberregex
Regular expressions that match the mobile phone number in mainland China. / δΈη»εΉι
δΈε½ε€§ιζζΊε·η ηζ£ε葨达εΌγ
Stars: β 4,440 (+12958.82%)
Mutual labels: regex, regular-expression
Moses
Utility library for functional programming in Lua
Stars: β 541 (+1491.18%)
Mutual labels: functional-programming, functional
Regexplain
π An RStudio addin slash regex utility belt
Stars: β 413 (+1114.71%)
Mutual labels: regex, regular-expression
Regexanalyzer
Regular Expression Analyzer and Composer for Node.js / XPCOM / Browser Javascript, PHP, Python
Stars: β 29 (-14.71%)
Mutual labels: composer, regular-expression
Regex
A sane interface for php's built in preg_* functions
Stars: β 909 (+2573.53%)
Mutual labels: regex, regular-expression
Picomatch
Blazing fast and accurate glob matcher written JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.
Stars: β 393 (+1055.88%)
Mutual labels: regex, regular-expression
Carp
Carp is a programming language designed to work well for interactive and performance sensitive use cases like games, sound synthesis and visualizations.
Stars: β 4,389 (+12808.82%)
Mutual labels: functional-programming, functional
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: β 641 (+1785.29%)
Mutual labels: regex, regular-expression
rexrex
π¦ Regular Expression utils that rock!
Create regular expressions that are composable, reusable, and commentable.
Getting started
yarn add rexrex
Utils
whole
whole('sentence to match') // -> ^sentence to match$
repeat
repeat('\\d') // -> \\d
repeat('\\d', 8) // -> \\d{8}
repeat('\\d', 1, 3) // -> \\d{1,3}
repeat('\\d', 1, Infinity) // -> \\d{1,}
numeric
Equivalent to rex.repeat.bind(null, '\\d')
alpha
Equivalent to rex.repeat.bind(null, '[A-z]')
and
and('a', 'b', 'c') // -> 'abc'
or
or('a', 'b', 'c') // -> 'a|b|c'
wildcard
and extra
wildcard('.') // -> '.*'
wildcard('.', true) // -> '.*?'
extra('.', matchers.LAZY) // -> '.+?'
extra('.', false) // -> '.+'
capture
capture('\\d+?') // -> (\\d+?)
or you can name your capture group with capture(pattern, name)
capture('\\d+?', 'number') // -> (?<number>\\d+?)
group
Similar to a capture(...), but won't keep the capture within the parentheses
group('.|\\s') // -> (?:.|\\s)
look.(ahead|behind).(positive|negative)
Creates a negative or positive look-ahead
look.ahead.positive('Y') === look.ahead('Y') // -> '(?=y)'
look.ahead.negative('Y') // -> '(?!y)'
look.behind.positive('Y') === look.behind('Y') // -> '(?<=y)'
look.behind.negative('Y') // -> '(?<!y)'
regex
Equal to RegExp
constructor
Matchers
-
ALPHA
:'[A-z]'
-
WORD
:'\\w'
-
NUMBER
:'\\d'
-
WHITE_SPACE
:'\\s'
-
ANY
:'.'
-
START
:'^'
-
END
:'$'
-
LAZY
:'?'
not
Matches opposite of matchers
regex(matchers.not.ALPHA) // -> '[^A-z]'
Flags
-
GLOBAL
:'g'
-
MULTI_LINE
:'m'
-
INSENSITIVE
:'i'
-
STICKY
:'y'
-
UNICODE
:'u'
Examples
See index.spec.js
for all the uses!
// found in `graphql-types-drivers-license`
// Matches all New York Driver's licenses
regex(
or(
and(alpha(1), numeric(7)),
and(alpha(1), numeric(18)),
and(numeric(8, 9)),
and(numeric(16)),
and(alpha(8))
)
)
// -> /[A-z]{1}\d{7}|[A-z]{1}\d{18}|\d{8,9}|\d{16}|[A-z]{8}/
// matches GraphQL queries/mutations
regex(
and(
capture(
and(
capture(or(...GQL_TYPES)),
extra(SPACE),
extra(WORD),
extra(SPACE),
wildGroup(and('on', extra(SPACE), extra(WORD)))
)
),
wildcard(SPACE),
wildGroup(
and(extraGroup(and('{', extraGroup(CHARS))), extraGroup(and('}', extraGroup(CHARS))))
),
'}'
),
flags.GLOBAL
)
// -> /((fragment|query|mutation|subscription)\s+\w+\s+(on\s+\w+)*)\s*(({(\s|\w|(".*")|:|,|\.|\)|\()+)+(}(\s|\w|(".*")|:|,|\.|\)|\()+)+)+}/g
Bonus
- Tiny!
- Super-readable!
- Changes make sense!
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].