Skip to content

Instantly share code, notes, and snippets.

@yuanqing
Created July 5, 2015 12:38
Show Gist options
  • Save yuanqing/a8b3453e58a578d7695d to your computer and use it in GitHub Desktop.
Save yuanqing/a8b3453e58a578d7695d to your computer and use it in GitHub Desktop.
'use strict';
var str = 'foobarbaz';
var regexp = /bar/;
console.log(str.match(regexp)); //=> [ 'bar', index: 3, input: 'foobarbaz' ]
console.log(regexp.exec(str)); //=> [ 'bar', index: 3, input: 'foobarbaz' ]
console.log(regexp.test(str)); //=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment