ID:2554601
 
Resolved
splittext() with a regular expression did not handle regex capturing groups correctly, and instead captured the whole regular expression match instead of just the group.
BYOND Version:513.1517
Operating System:Windows 10 Home
Web Browser:Firefox 74.0
Applies to:Dream Daemon
Status: Resolved (513.1518)

This issue has been resolved.
Descriptive Problem Summary:
The documentation of splittext states that if a regular expression is used as the delimiter, any capturing groups in the expression will be included in the list, in order. It seems that the actual behaviour is that these group matches are replaced by the match of the whole regex instead.

Numbered Steps to Reproduce Problem:
1.) Call splittext on a string with a regex delimiter which contains at least one capturing group.

Code Snippet (if applicable) to Reproduce Problem:
world.log << json_encode(splittext("XabXabX", regex("a((b))")))


Expected Results:
["X","b","b","X","b","b","X"]

Actual Results:
["X","ab","ab","X","ab","ab","X"]

Does the problem occur:
Every time? Or how often?Every time.
In other games?N/A
In other user accounts?Yes.
On other computers?Yes.

When does the problem NOT occur?
It seems to occur always.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked?
I haven't found a version without this bug but I admit I only checked a few (513.1513 does have this bug).

Workarounds:

Lummox JR resolved issue with message:
splittext() with a regular expression did not handle regex capturing groups correctly, and instead captured the whole regular expression match instead of just the group.
Nice find. I don't know how I brainfarted so bad on this but this one's been in for a while.