Skip to content
Advertisement

Split does not separate string

I need to break a string into several parts and for that I did a split, but the split doesn’t break the string. It returns an array with only one value and my string inside [“9月 28, 2021”] I expected it to return an array with [9], [月], [28], [2021]. I think JS gets lost with the 月 character, I honestly don’t know what to do.

JavaScript

Advertisement

Answer

You can get the expected result by spliting word boundaries b in addition to spaces, and commas.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement