The nxo_regex class is a subclass of the nxo class.
This function combines nxo_regex_new() and nxo_regex_match() in such a way that no Onyx regex object is created, thus providing a more efficient way of doing a one-off match.
If there are capturing subpatterns in the regular expression, also create substrings for those capturing subpatterns and insert them into the substring array.
As a special case, if the regular expression matches the empty string, split a single character. This avoids an infinite loop.
As a side effect, set the thread's match cache, which can be queried via nxo_regex_submatch(). Keep in mind that this function can match multiple times in a single invocation, so only the last match is available in this way.
If there are capturing subpatterns in the regular expression, also create substrings for those capturing subpatterns and insert them into the substring array.
As a special case, if the regular expression matches the empty string, split a single character. This avoids an infinite loop.
As a side effect, set the thread's match cache, which can be queried via nxo_regex_submatch(). Keep in mind that this function can match multiple times in a single invocation, so only the last match is available in this way.
This function combines nxo_regex_nex() and nxo_regex_split() in such a way that no Onyx regex object is created, thus providing a more efficient way of doing a one-off split.
Each thread has a match cache that is used by various regex and regsub functions. That cache stores a reference to the string that was most recently matched against, as well as offsets and lengths of the match and capturing subpatterns. Since creating substrings puts pressure on the garbage collector, substring creation is done lazily (i.e. when this function is called). Normally, a program has little need to ask for the same substring twice, so the created substrings are not cached. That means that if this function is called twice in succession with the same arguments, two different (but equivalent) substrings will be returned.