Skip to content

Request to improve betweenΒ #224

@LeeeRoux

Description

@LeeeRoux

I request to improve between
It should get all the values between left and right and return an Array of them
null incase there was no any values

/*S.prototype.between*/
function(qu1 = '"', qu2 = qu1) {
 var toReturn = [], f = false, str = this.s || this;
 for (var i = 0; i < str.length; i++) { 
  if (str.indexOf(qu1) > -1 && !f) { f = true; str = str.slice(str.indexOf(qu1) + qu1.length); };
  if (str.indexOf(qu2) > -1 && f) { 
   var value = str.substring(0, str.indexOf(qu2))
    str = str.slice(str.indexOf(qu2) + qu2.length);
    toReturn.push(value);
    f = false;
  }
 };
return toReturn.length ? toReturn : null;
}

Tested and works correctly

 "`Hello``World`".between("`");
//["Hello", "World"]

Please add it, Thankyou!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions