Nodejs String Split rsplit(sep, maxsplit)

Here you can find the source of rsplit(sep, maxsplit)

Method Source Code

String.prototype.rsplit = function(sep, maxsplit) {
  var split = this.split(sep);
  return maxsplit ? [ split.slice(0, -maxsplit).join(sep) ].concat(split.slice(-maxsplit)) : split;
};

Related

  1. splitStr(delimiter)
    function reverseWords(str) {
      var result = "";
      var wordArray = str.split(" ");
      for (var i = wordArray.length - 1; i >= 0; i--) {
        result += wordArray[i] + " ";
      return result.trim(); 
    String.prototype.splitStr = function (delimiter) {
    ...
    
  2. splitWord()
    String.prototype.splitWord = function () {
      return this.split(/(?=[A-Z])/).join(' ');
    };
    
  3. splitchunks(s)
    String.prototype.splitchunks = function(s) {
      return s.split(/\n\n+/) 
    
  4. splitenum(separator)
    String.prototype.splitenum = function(separator){
        var tokens = this.split(separator);
        var obj = {}
        for (var i=0; i< tokens.length; i++ ){
            obj[i] = tokens[i];
        return obj;
    
  5. splitlines(s)
    String.prototype.splitlines = function(s) {
      return s.split('\n') 
    
  6. rsplit(sep, maxsplit)
    String.prototype.rsplit = function(sep, maxsplit) {
        var split = this.split(sep);
        return maxsplit ? [ split.slice(0, -maxsplit).join(sep) ].concat(split.slice(-maxsplit)) : split;
    var graphs = [];
    var URL_SEP = "/";
    var blank_uuid = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    function swapLastPart(url, lastPart) {
      return swapLastParts(url, [lastPart]);
    ...