AtomVM icon indicating copy to clipboard operation
AtomVM copied to clipboard

Regex support

Open jgonet opened this issue 8 months ago • 1 comments

Currently, AtomVM has non-existent support for Regex. It comes up in few places in Elixir (=~ operator, regex sigils, Regex module). OTP has fork of PCRE with few adjustments. Regex engines tend to be big in codesize and most projects opt for PCRE (1 or 2). The alternative with really limited features I found is tiny-regex-c.

I built pcre2 in release mode and seems like all object files are 540K total. I wonder if having an (off by default) option to include regex engine would be considered. I'm thinking of a bit simplistic approach where we don't yield from C functions like ERTS does.

jgonet avatar Apr 24 '25 18:04 jgonet

I looked at tiny-regex-c and that looks perfect for microcontrollers, implemented as as resource nifs for re_compile() and re_matchp(), re_match() looks like it could be a plain nif. I don't know if this minimalist regex implementation will meet the needs of PopCorn, but this (from the tiny-regex-c README) looks attractive on any constrained environment:

> gcc -Os -c re.c
> size re.o
    text     data     bss     dec     hex filename
    2404        0     304    2708     a94 re.o

UncleGrumpy avatar Nov 20 '25 02:11 UncleGrumpy