#Strange .split behaviour

11 messages · Page 1 of 1 (latest)

frail copper
#

I have String "M3M4M8M8M8" when I split it with .split("M") I get
[, 1, 1, 1, 1, 1], why ?? I shoud be getting [3, 4, 8, 8, 8]

quartz basinBOT
#

This post has been reserved for your question.

Hey @frail copper! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

outer loom
#

/run

System.out.println(java.util.Arrays.toString("M3M4M8M8M8".split("M")));
steady lakeBOT
#

Here is your java(15.0.2) output @outer loom

[, 3, 4, 8, 8, 8]
outer loom
#

yeah that's not what's going on here

#

you have a different string from that

frail copper
#

oh

outer loom
#

the empty string at the start is the proper behavior

frail copper
#

ok thanks

quartz basinBOT
# frail copper ok thanks

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.