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.
Discussions

JavaScript String.split(RegExp) is returning empty strings
So, I believe that what's going on here is that the Javascript you are running is using the split method, while the regex is matching. Split is actually "splitting" the string into parts. So when it matches the dot . in your regex, it splits it into document, ., write, . Your regex, on the other hand matches the dot .. You see that just with the first character, you're already skewed 3 to 1. If you're wanting to replicate the functionality of what you have on regex101, you'd want to use the match instead. Here is a demo More on reddit.com
🌐 r/regex
5
2
July 19, 2017
RegEx: How to Split String into Words
I continue to struggle with translating a RegEx pattern that works in the Online RegEx tool to one that works in the KM action for Search Using Regular Expression. BTW, I know this is easily done in JavaScript, but I need it to work in just KM. ###How to I make this pattern work in KM: ... More on forum.keyboardmaestro.com
🌐 forum.keyboardmaestro.com
0
December 11, 2015
Complex split using Regex
Hello, I am working a discrete math parser to turn equations into abstract syntax trees. "!!(a)" To do this, I must the string above into the following: ["!!(", "a", ")"] If an exclamation point is before an open parenthesis or letters, then split at that point. More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
November 5, 2022
How to split strings using regular expressions in JavaScript
I need help with processing short strings that are maximum 8 characters long. Here are some examples: // sample data to show different cases var examples = [ '22222222', '3XCM7', '45Y8' ] I want to create a function that finds consecutive number characters and adds them up. More on community.latenode.com
🌐 community.latenode.com
0
May 28, 2025
🌐
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 regular expression with capturing groups, then each time separator matches, the captured groups (including any undefined results) are spliced into the output array. This behavior is specified by the regexp's Symbol.split method. If separator is an object with a Symbol.split ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-string-split-example-with-regex
JavaScript String.Split() Example with RegEx - GeeksforGeeks
August 5, 2025 - The String.split() method in JavaScript ... 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 - You Can Include Delimiters In The Result Of JavaScript's String .split() Method When Using Capturing Groups
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › RegExp › Symbol.split
RegExp.prototype[Symbol.split]() - JavaScript | MDN
July 10, 2025 - 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.
🌐
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.

Find elsewhere
🌐
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 - The split() method in JavaScript is used to divide a string into an array of substrings based on a specified delimiter. By default, split() can take a simple string delimiter, but its real power comes from using regex as the delimiter.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Regular_expressions
Regular expressions - JavaScript | MDN
This allows you to do new RegExp(RegExp.escape("a*b")) to create a regular expression that matches only the string "a*b".
🌐
Keyboard Maestro
forum.keyboardmaestro.com › questions & suggestions
RegEx: How to Split String into Words - Questions & Suggestions - Keyboard Maestro Discourse
December 11, 2015 - I continue to struggle with translating a RegEx pattern that works in the Online RegEx tool to one that works in the KM action for Search Using Regular Expression. BTW, I know this is easily done in JavaScript, but I need it to work in just KM. ###How to I make this pattern work in KM: /"[^"]*"|[^:]+/g For the string "10:05:12:00" it should return 4 match groups, but it shows only one.
🌐
Medium
medium.com › nerd-for-tech › basics-of-javascript-string-split-method-4647aa1b0f4e
Basics of Javascript · String · split() (method) | by Jakub Korch | Nerd For Tech | Medium
June 20, 2021 - Therefore our emoji symbol is split into its code unit values as we see in the output. If we use regular expression, the exact match has to be found, otherwise the result is an array with one element consisting of the entire string.
🌐
W3Schools
w3schools.com › jsref › jsref_split.asp
JavaScript String split() Method
If (" ") is used as separator, the string is split between words. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you ...
🌐
ReqBin
reqbin.com › code › javascript › wyqvcilw › javascript-split-string-example
How do I split a string in JavaScript?
February 10, 2023 - To split a string in JavaScript, you can use the string.split(separator, limit) method. The split() method splits the given string into an array of strings using "separator" as the delimiter.
🌐
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 "."....
🌐
Latenode
community.latenode.com › other questions › javascript
How to split strings using regular expressions in JavaScript - JavaScript - Latenode Official Community
May 28, 2025 - I need help with processing short strings that are maximum 8 characters long. Here are some examples: // sample data to show different cases var examples = [ '22222222', '3XCM7', '45Y8' ] I want to create a…
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-string-split-method
JavaScript String split() Method - GeeksforGeeks
... separator: It is used to specify the character, or the regular expression, to use for splitting the string. If the separator is unspecified then the entire string becomes one single array element.
Published   January 16, 2026
🌐
SPGuides
spguides.com › split-string-by-regex-in-typescript
How to Split Strings by Regex in TypeScript
December 23, 2023 - For example, let result = “Hello World from TypeScript”.split(/\s/); will split the string at every whitespace, returning an array of substrings. ... Regex can be used to check if a string contains the specified search pattern in Typescript.
🌐
Sentry
sentry.io › sentry answers › javascript › split a string in javascript
Split a string in JavaScript | Sentry
const myString = "This is a sentence."; const words = myString.split(" "); // split on single space characters console.log(words); // will output ["This", "is", "a", "sentence."] The separator can be a string or a regular expression, so we could also do something like this:
🌐
Codingem
codingem.com › home › split string in javascript: a complete guide (with examples)
Split String in JavaScript: A Complete Guide (with Examples)
July 10, 2025 - In JavaScript, the string type has a built-in method called split(). You can use this method to split a string by a specific separator, such as a blank space or a dash.