Skip to content

Instantly share code, notes, and snippets.

Created April 25, 2014 04:54
Show Gist options
  • Select an option

  • Save anonymous/11278042 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/11278042 to your computer and use it in GitHub Desktop.
/(\bcss3|svg\b)+|https?:\/\/(www\.)?\w+\.\w+\/(\-css3|svg\-)/ig
@1Marc
Copy link
Copy Markdown

1Marc commented Apr 25, 2014

var reg = new RegExp("/(\bcss3|svg\b)+|https?://(www.)?\w+.\w+\/(-css3|svg-)/ig");
reg.test("I love this thing about SVG. http://foo.com/article"); // returns false, should return true
reg.test("This is awesome http://super-awesome-svg.com"); // returns false, should return true
reg.test("I <3 this css3 button thing http://codepen.com/abcdefg"); // returns false, should return true
reg.test("This is a thing we are testing. It should not match this http://t.co/ifesVgief"); // returns false
reg.test("Boogy buggy booger. It should not match this http://t.co/ewfijCSs3few"); // returns false

@jonfriskics
Copy link
Copy Markdown

var reg = new RegExp(/(\bcss3|svg\b)+|https?:\/\/(www.)?\w+.\w+\/(-css3|svg-)/ig);

Regular Expressions don't get quoted when you're passing it into RegExp

@1Marc
Copy link
Copy Markdown

1Marc commented Apr 25, 2014

Oops! Awesome you're amazing!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment