4 examples of 'mdn string split' in JavaScript

Every line of 'mdn string split' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
157function splitString(string) {
158 return string.split(new RegExp(separators.join('|'), 'g'));
159}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

64splitString(str) {
65 try {
66 return str ? str.split(this.delimStr) : [];
67 }
68 catch (error) {
69 return str;
70 }
71}
69function split(str) {
70 if (str.slice(0, 3) !== '---') return;
71 const matcher = /\n(\.{3}|-{3})/g;
72 const metaEnd = matcher.exec(str);
73 return metaEnd && [str.slice(0, metaEnd.index), str.slice(matcher.lastIndex)];
74}
144function splitString(value) {
145 return value.split(/\s+/g);
146}

Related snippets