The bug
The regex for integer arrays to distinct them from lists is
\[[-+\d|,\s]+\]
This matches int array items things like
+++ --- +-+- 1+1 1 \t\n\x0B\f\r4
which cannot be parsed as integers.
Note: It might be good if the string would be parsed as list if it could not be parsed as integer array, because a NBT list would be more obvious than a NBT string given that it matched the list requirements in the first place.
How to reproduce
- Use the following command
/give @p stone 1 0 {IntArrayTest:[+++,---,+-+-]}
- Throw the item on the ground and inspect its NBT data
/entitydata @e[type=item,c=1] {}
→ You will see that the tag IntArrayTest is a String (IntArrayTest:"[+++,---,+-+-]") instead of a list (IntArrayTest:["+++","---","+-+-"]), which means it matched the integer array pattern but could not be converted to an integer array
Suggested regex
The suggested regex could for example be
\[(?:[+-]?\d+\s*,\s*)*(?:[+-]?\d+)\]
or maybe with additional whitespaces in case somebody wants to parse a pretty printed integer array:
\[\s*(?:[+-]?\d+\s*,\s*)*[+-]?\d+\s*,?\]
- relates to
-
MC-97662 NBT parser regex checks for pipebars as tag declaration
- Resolved