You need the put the characters you wish to split on in a character class, which tells the regular expression engine "any of these characters is a match". For your purposes, this would look like:

date.split(/[.,\/ -]/)

Although dashes have special meaning in character classes as a range specifier (ie [a-z] means the same as [abcdefghijklmnopqrstuvwxyz]), if you put it as the last thing in the class it is taken to mean a literal dash and does not need to be escaped.

To explain why your pattern didn't work, /-./ tells the regular expression engine to match a literal dash character followed by any character (dots are wildcard characters in regular expressions). With "02-25-2010", it would split each time "-2" is encountered, because the dash matches and the dot matches "2".

Answer from Daniel Vandersluis on Stack Overflow
🌐
freeCodeCamp
freecodecamp.org › news › javascript-string-split-example-with-regex
JavaScript String.Split() Example with RegEx
May 26, 2022 - The split method uses characters that match this pattern as a breakpoint, and as you can see, the "$e" in "$everything" and the "$o" in "g$oing" served as a breakpoint to split the string into substrings. You do not need to apply the global flag g in the regex, as the split method already looks for all occurrences of the regex pattern as the breakpoint.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › split
String.prototype.split() - JavaScript | MDN
If separator is a string, an Array of strings is returned, split at each point where the separator occurs in the given string. If separator is a regex, the returned Array also contains the captured groups for each separator match; see below for details.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › RegExp › Symbol.split
RegExp.prototype[Symbol.split]() - JavaScript | MDN
Integer specifying a limit on the number of splits to be found. The [Symbol.split]() method still splits on every match of this RegExp pattern (or, in the Syntax above, regexp), until the number of split items match the limit or the string falls short of this pattern.
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-split-string-by-regex
How to Split a String by a Regex in JavaScript | bobbyhadz
Pass a regular expression as a parameter to the String.split() method to split a string by a regex. The split method takes a string or regular expression and splits the string based on the provided separator, into an array of substrings. index.js ...
🌐
DEV Community
dev.to › tpointtech123 › a-guide-to-splitting-strings-in-javascript-by-regex-4hg3
A Guide to Splitting Strings in JavaScript by Regex - DEV Community
March 20, 2025 - To learn more about using regex ... at all levels. The split() method in JavaScript is used to divide a string into an array of substrings based on a specified delimiter....
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-string-split-example-with-regex
JavaScript String.Split() Example with RegEx - GeeksforGeeks
August 5, 2025 - JS Tutorial · Web Tutorial · ... with simple delimiters like spaces or commas, you can use Regular Expressions (RegEx) for more advanced and flexible string splitting....
🌐
Bennadel
bennadel.com › blog › 4628-understanding-regexp-capture-groups-when-using-split-in-javascript.htm
Understanding RegExp Capture Groups When Using .split() In JavaScript
April 2, 2024 - It turns out that captured groups are included in the .split() result as individual array elements. Let's see this in action.
Find elsewhere
🌐
Self-Host Kutt With Docker
paulsblog.dev › manipulate-strings-with-regular-expression-in-javascript
Manipulate Strings With Regular Expressions In JavaScript
March 14, 2025 - This rather complex Regex will ... any String can be split into an array of Substrings by using the split() function with a separator like " ", ",", or "."....
🌐
ReqBin
reqbin.com › code › javascript › wyqvcilw › javascript-split-string-example
How do I split a string in JavaScript?
const str = 'JavaScript+Split-String'; const separators = [' ', '\\\+', '-', '\\\(', '\\\)', '\\*', '/', ':', '\\\?']; let result = str.split(new RegExp(separators.join('|'), 'g')); console.log(result); // output: ['JavaScript', 'Split', 'String']
🌐
DEV Community
dev.to › abhiweb › use-regex-to-split-a-string-in-javascript-preserving-separators-notes-1g8d
Use RegEx to split a string in Javascript (preserving separators) | Notes - DEV Community
February 2, 2021 - #notes #regex #javascript #recipe · Use the Javascript split() function with a Positive Lookbehind Regular Expression to split a string while preserving the separators in the sub-strings: split(/(?<=[<separator characters go here>])/) Lookbehind ...
🌐
Wisdom Geek
wisdomgeek.com › development › web-development › javascript › javascript-split-string-and-keep-the-separators
JavaScript: Split string and keep the separators - Wisdom Geek
October 10, 2023 - String.prototype.split() is a valuable method to split strings based on a delimiter. There often comes a scenario when we want to split a string and keep the separators in the result.
🌐
W3Schools
w3schools.com › jsref › jsref_split.asp
JavaScript String split() Method
apply() construct() defineProperty() deleteProperty() get() getOwnPropertyDescriptor() getPrototypeOf() has() isExtensible() ownKeys() preventExtentions() set() setPrototypeOf() JS RegExp Patterns · /d /g /i /m /s /u /v /y [a] [^a] [abc] [^abc] [A-Z] [^A-Z] [0-9] [^0-9] a|b .
🌐
DEV Community
dev.to › dillionmegida › string-split-in-javascript-2a0d
String.split() in Javascript - DEV Community
April 19, 2020 - The regex matches strings with one number (\d{1}) and one character (.{.{1}), hence those points are replaced with breakpoints. We can't use string breakpoints for such cases because of the various combinations of letters and characters. const str = 'String.split() in 1b in 1c in Javascript article' const pieces = str.split(/.{2}in.{2}/); console.log(pieces) // Expected output // [ 'S', 'split(', '', '', 'avascript article' ]
🌐
Reddit
reddit.com › r/regex › javascript string.split(regexp) is returning empty strings
r/regex on Reddit: JavaScript String.split(RegExp) is returning empty strings
July 19, 2017 -

So I have this regular expression:

/([\s+\-*\/%=&^|<>~"`!;:,.?()[\]{}\\])/g

which should match all whitespace, and +-*/%=&|<>~"`!;:,.?()[]{}]\

(and the up caret, but reddit is being annoying)

On regex websites like this one, you can see that the Regular Expression works how I'd like it to, however if you run the JavaScript String.split, it returns all the matches I want, and the text in between matches which I also want. The issue is it also returns some empty strings, which I don't want.

Run this in your browser and you'll see what I mean:

`document.write("<h2>Table of Factorials</h2>");
for(i = 1, fact = 1; i < 10; i++, fact *= i) {
    document.write(i + "! = " + fact);
    document.write("<br>");
}`.split(/([\s+\-*\/%=&^|<>~"`!;:,.?()[{\]}\\])/g);

The expected result is something like:

["document", ".", "write", "(", """, "<", "h2", ">", "Table", " ", "of", " ", "Factorials", "<", "/", "h2", ">", """, ")"...]

however, the actual result is:

["document", ".", "write", "(", "", """, "", "<", "h2", ">", "Table", " ", "of", " ", "Factorials", "<", "", "/", "h2", ">", "", """, "", ")"...]

Why am I getting some empty strings back? How can I fix it? Thank you for your time.

🌐
TechOnTheNet
techonthenet.com › js › string_split.php
JavaScript: String split() method
Optional. It is delimiter used to break the string into the array of substrings. It can be a single character, string or regular expression. If this parameter is not provided, the split() method will return an array with one element containing the string.