Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Created July 8, 2015 20:27
Show Gist options
  • Save JavaScript-Packer/6fab628f0d147a6b58b1 to your computer and use it in GitHub Desktop.
Save JavaScript-Packer/6fab628f0d147a6b58b1 to your computer and use it in GitHub Desktop.
Tiny minified JavaScript function to find out if a string contains a search word/tern using regex. Live demo on http://jsfiddle.net/apmepe5j/
function is_in(a,b,c,d){return c=RegExp(b),d=c.test(a)}
alert(is_in("WHAK.com's awesome haystack!","needle"));
//returns false
alert(is_in("WHAK.com's awesome haystack!","some"));
//returns true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment