Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

prevOpen Source→ranges-regexnext

ranges-regex6.2.1

Integrate regex operations into Ranges workflow

Downloads per monthChangelogMIT Licenselibera manifesto
  • the top
  • Installation
  • Quick Take
  • Examples
  • PURPOSE
  • API — RREGEX()
  • API — VERSION
  • Changelog

Installation

Quick Take

Examples

  • Clashing replacement values
  • Give deletion precedence with a null replacement
  • Require the global flag so every match can be collected safely
  • Slice the source text using the returned ranges
  • Merge adjacent regex matches into one range
  • Nothing was found
  • Replacing values
  • Advance over a complete Unicode code point after an empty match
  • Turn zero-width matches into insertion ranges

Purpose

This program converts the regex matches into ranges array so that continue to use the Ranges workflow — process the string in composable fashion — gather many pending string amendment operations, reason about them, process them, and finally, in the end, “render” ranges into the result string and do it only once.

API — rRegex()

The main function rRegex() is imported like this:

It’s a function which takes three input arguments:

This package does not mutate its inputs.

Input argumentTypeObligatoryDescription
regx
Type: Regular expression
Obligatory: yes
regxRegular expressionyesProvide the regexp to apply onto a string
str
Type: String
Obligatory: yes
strStringyesProvide a string upon which to match the regex
replacement
Type: String or null
Obligatory: no
replacementString or nullnoIf you want to add a third argument on every of the finding’s third argument values, put it here.

Function will return ranges — a null (theoretically possible) or array of one or more range arrays:

Tip: You can use all the features of regexes: global, case insensitive flags and so on.

API — version

You can import version:

Changelog

Open Changelog
↑ back to top
prev next

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab