Skip to content

Instantly share code, notes, and snippets.

@muhqu
Created July 19, 2011 13:34
Show Gist options
  • Save muhqu/1092344 to your computer and use it in GitHub Desktop.
Save muhqu/1092344 to your computer and use it in GitHub Desktop.
function (doc) {
// DOESN'T WORK:
var version = /(\d+)\.?(\d+)?\.?(\d+)?/.exec("1.3");
emit(version);
}
[info] [<0.6354.4>] OS Process #Port<0.3446> Log :: function raised exception (new TypeError("/(\\d+)\\.?(\\d+)?\\.?(\\d+)?/.exec is not a function", "", 2)) with doc._id bf7b2575897460c9a5543a1f153089c8
function (doc) {
// WORKS:
var version = ("1.3").match(/(\d+)\.?(\d+)?\.?(\d+)?/);
emit(version);
var version = new RegExp(/(\d+)\.?(\d+)?\.?(\d+)?/).exec("1.3");
emit(version);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment