mathieuprog

mathieuprog

This library allows you to get all the strings that a regex can match.

Examples:

import RegexToStrings

regex_to_strings("11|2[25]2") == {:ok, ["11", "222", "252"]}

regex_to_strings!("8(024|53)9") == ["80249", "8539"]

regex_to_strings!("(16|7?[56])24") == ["1624", "524", "7524", "624", "7624"]

regex_to_strings!("1[03-59]") == ["10", "13", "14", "15", "19"]

regex_to_strings("1.+2") == :unsupported_regex

regex_to_strings!("1.+2") # RuntimeError: unsupported metacharacter "."

https://github.com/mathieuprog/regex_to_strings

Showing Posts 1 to 5

a8t

a8t

Aren’t there infinitely many matches in some (most) cases?

Nicd

Nicd

Can you add a link to the library? :slight_smile:

mathieuprog

mathieuprog OP

Oops, ty! Done!

assert_raise RuntimeError, "unsupported metacharacter \".\"", fn ->
  regex_to_strings!("1.1")
end

assert regex_to_strings("1.+2") == :unsupported_regex

Ty updated the examples to reflect that:)

dimitarvp

dimitarvp

Maybe you should rebrand this library to something like string_generator because technically you are not actually supporting regexes. You are supporting a reduced subset of them.

mathieuprog

mathieuprog OP

The original use case is generating a list of possible values from a regex, so I keep the name because personally my goal was not to generate strings.

For example a Jamaican international number starts with “1” and then “658|876” according to Google’s libphonenumber. This library allows me to have the list of the possible values, i.e. “1658”, “1876”.

However it’s true that it could be used to generate a non-trivial series of numbers/strings:)

— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
CodeSync
:microphone: ElixirConf 2026 - Call for Talks is open! We’re heading to Chicago :united_states: :round_pushpin: In person + virtual :d...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews