Skip to content

Instantly share code, notes, and snippets.

@maolion
Created August 20, 2016 10:38
Show Gist options
  • Select an option

  • Save maolion/60c97115921f2785bbbd0eb91c71b717 to your computer and use it in GitHub Desktop.

Select an option

Save maolion/60c97115921f2785bbbd0eb91c71b717 to your computer and use it in GitHub Desktop.
function x() {
var patterns = [];
for (var i = 0; i < 9; i++) {
for (var i2 = 0; i2 < 9; i2++) {
patterns.push(
'(?:' + i2 + '<=?' + '['+(i2+1)+'-9](?:\\.\\d*)?|' + i2 + '>=?(?:[0-' + Math.max(i2-1, 0) + '])(?:\\.\\d*)?)'
);
}
patterns.push('(?:'+ i +'[><]='+ i +')');
patterns.push('(?:' + i + '<[1-9]\\d+(?:\\.\\d*)?|' + i + '>-\\d(?:\\.\\d*)?)');
}
return patterns.join('|');
}
var r = new RegExp('(?:' + x() + ')\\s*&&\\s*(?:' + x() + ')')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment