Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Last active January 5, 2016 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JavaScript-Packer/6be2d8deb3675006c2a8 to your computer and use it in GitHub Desktop.
Save JavaScript-Packer/6be2d8deb3675006c2a8 to your computer and use it in GitHub Desktop.
www.whak.ca/between-parser.htm Parse a string for variables found between 2 smaller strings. Good for parsing all data from all the data say held between quotes or brackets.
function parseBetween(s, b, b2, j) {
var x = [];
var a = s.split(b);
for (var i = 1; i < a.length; i++) if (true == function(z) {
return z % 2;
}(i)) x.push(a[i].split(b2));
if ("" == j) return x; else return x.join(j);
}
var str = 'hello, my website is "www.WHAK.ca", my friend\'s site is "www.BibleHunter.com". what\'s yours?';
document.writeln(parseBetween(str, '"', '"', "<hr>"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment