Last active
January 5, 2016 18:27
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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