Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request to improve between #224

Open
LeeeRoux opened this issue Oct 19, 2018 · 0 comments
Open

Request to improve between #224

LeeeRoux opened this issue Oct 19, 2018 · 0 comments

Comments

@LeeeRoux
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant