Skip to content

Instantly share code, notes, and snippets.

@btk
Created May 25, 2016 12:44
Show Gist options
  • Save btk/7a1406463de116b90a304a5ffa2372ff to your computer and use it in GitHub Desktop.
Save btk/7a1406463de116b90a304a5ffa2372ff to your computer and use it in GitHub Desktop.
function getFirstMatch(beginsWith, endsWith, myStr){
var strSplit = myStr.split(beginsWith);
var strSplit2 = strSplit[1].split(endsWith);
return strSplit2[0];
}
//usage
console.log(getFirstMatch("{{", "}}", "Foo Faa {{Foo1234Faa789863Whateva}}"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment