HaxeFoundation / HaxeFoundation/haxe
clarify EReg.matched spec regarding capture groups
Open
documentation
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
So currently the doc for `EReg.matched` says this:
> The index `n` corresponds to the n-th set of parentheses in the pattern
of `this` EReg. If no such sub-group exists, the result is unspecified.
But it's not immediately clear what "no such sub-group exists" means exactly. I assume it means that the group was not defined in the regex. But it's a bit confusing in case the group _was_ defined but was not matched.
I.e. is it safe to rely on the following to consistently trace an empty string?
```haxe
var r = ~/(a)?b/;
if (r.match("b")) {
trace(r.matched(1));
}
```
Contributor guide
Assessment
This issue has not been assessed yet.