Skip to main content
The iodine/regex.ih library provides find and split. Despite its name, this is a small pattern matcher, not a complete POSIX or PCRE regular-expression engine.

Supported pattern syntax

The implementation does not provide grouping, alternation, +, ?, or anchors such as ^ and $. Treat unsupported metacharacters as ordinary characters; do not assume behavior from a larger regex standard.

Find a match

find(text, pattern) searches from left to right and returns the first matched substring. It returns an empty string when it finds no non-empty match.
Expected output:
Because * can match zero characters, a pattern such as a* can produce an empty match at an earlier position and prevent find from reaching a later non-empty match. An empty return therefore does not distinguish “no match” from “matched zero characters.”

Split text

split(text, pattern) finds each delimiter match and returns the pieces joined with newline characters:
The resulting string contains:
split returns one string, not an array. The separator between resulting pieces is a newline.

Implementation notes

The matcher tries possible start positions from left to right. * is greedy and the implementation backtracks to try matching the remaining pattern. It returns the matched substring, not its start index or capture groups. See the regex library source for the implementation.