You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As commented in the Javadoc [1], unfortunately java.lang.String.split emulation has a lot of incompatibilities with JDK. String.split is using regular expressions, and it is impractical to ship a complete Java compatible regex emulation to web. Instead we cheat in this method, try to mimic Java split behavior using JS regex. Although it works mostly the same, this results in different behavior for many edge cases.
Depend on your use case, one alternative API that would work consistently with JVM is the Guava's Splitter which doesn't use regex.
(Being said that split("") is surprisingly uncommon so maybe it is worthwhile special case that scenario 😞 )
[1]
Regular expressions vary from the standard implementation. The regex parameter is interpreted by JavaScript as a JavaScript regular expression. For consistency, use only the subset of regular expression syntax common to both Java and JavaScript.
(Note: in offline discussion rluble@ pointed out that the JDK behavior is actually changed from Java 7 to Java 8 where J2CL is following the earlier behavior)
Describe the bug
"abc".split("") get error array ["","a","b","c"]
To Reproduce
use j2clmavenplugin
get result in browser console
"abc".split("") The expected result is ["a","b","c"]
The text was updated successfully, but these errors were encountered: