Skip to content

Instantly share code, notes, and snippets.

@raspo
Created June 28, 2012 08:17
Show Gist options
  • Save raspo/3009858 to your computer and use it in GitHub Desktop.
Save raspo/3009858 to your computer and use it in GitHub Desktop.
Split string only once
function splitOnce( str, sep ){
var components = str.split( sep ),
result = [];
result[0] = components.shift();
result[1] = components.join( sep );
return result;
}
// Example
var string = 'key=value&key2=value2&key3=value3';
splitOnce( string, '=' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment