verbal-expressions
Advanced tools
Comparing version 0.2.0 to 0.2.1
/*! | ||
* VerbalExpressions JavaScript Library v0.2.0 | ||
* VerbalExpressions JavaScript Library v0.2.1 | ||
* https://github.com/VerbalExpressions/JSVerbalExpressions | ||
@@ -46,3 +46,2 @@ * | ||
VerbalExpression.prototype = { | ||
// Variables to hold the whole | ||
@@ -59,2 +58,3 @@ // expression construction in order | ||
var reRegExpEscape; | ||
if (value.source) { | ||
@@ -206,2 +206,3 @@ return value.source; | ||
this.add('[' + value + ']'); | ||
return this; | ||
@@ -307,16 +308,16 @@ }, | ||
var value; | ||
var values; | ||
var i; | ||
if (arguments.length <= 1) { | ||
if (/\d+/.exec(arguments[0]) !== null) { | ||
value = '{' + arguments[0] + '}'; | ||
var reIsInteger = /\d+/; | ||
var length = arguments.length; | ||
var values = new Array(length); | ||
var i = 0; | ||
var j = 0; | ||
for (i = 0; i < length; i++) { | ||
if (reIsInteger.test(arguments[i])) { | ||
values[j++] = arguments[i]; | ||
} | ||
} else { | ||
values = []; | ||
for (i = 0; i < arguments.length; i++) { | ||
if (/\d+/.exec(arguments[i]) !== null) { | ||
values.push(arguments[i]); | ||
} | ||
} | ||
} | ||
if (j > 0) { | ||
// Set the new length of the array, thus reducing to the elements that have content | ||
values.length = j; | ||
value = '{' + values.join(',') + '}'; | ||
@@ -398,8 +399,8 @@ } | ||
// Supports AMD, CommonJS and the browser | ||
if (typeof root.module !== 'undefined' && root.module.exports) { | ||
if (typeof module !== 'undefined' && module.exports) { | ||
// Node.js Module | ||
module.exports = createVerbalExpression; | ||
} else if (typeof root.define === 'function' && root.define.amd) { | ||
} else if (typeof define === 'function' && define.amd) { | ||
// AMD Module | ||
root.define(MODULE_NAME, [], function define() { | ||
define(MODULE_NAME, [], function define() { | ||
return VerbalExpression; | ||
@@ -406,0 +407,0 @@ }); |
/*! | ||
* VerbalExpressions JavaScript Library v0.2.0 | ||
* verbal-expressions JavaScript Library v0.2.1 | ||
* https://github.com/VerbalExpressions/JSVerbalExpressions | ||
@@ -9,7 +9,7 @@ * | ||
* | ||
* Date: 2016-01-12 | ||
* Date: 2016-01-22 | ||
* | ||
*/ | ||
!function(a){function b(){var a=new RegExp;return b.injectClassMethods(a),a}function c(){return new b}var d="VerEx";b.injectClassMethods=function(a){var c;for(c in b.prototype)b.prototype.hasOwnProperty(c)&&(a[c]=b.prototype[c]);return a},b.prototype={_prefixes:"",_source:"",_suffixes:"",_modifiers:"gm",sanitize:function(a){var b;return a.source?a.source:"number"==typeof a?a:(b=/([\].|*?+(){}^$\\:=[])/g,a.replace(b,"\\$&"))},add:function(a){return this._source+=a||"",this.compile(this._prefixes+this._source+this._suffixes,this._modifiers),this},startOfLine:function(a){return a=a!==!1,this._prefixes=a?"^":"",this.add(),this},endOfLine:function(a){return a=a!==!1,this._suffixes=a?"$":"",this.add(),this},then:function(a){return a=this.sanitize(a),this.add("(?:"+a+")"),this},find:function(a){return this.then(a)},maybe:function(a){return a=this.sanitize(a),this.add("(?:"+a+")?"),this},anything:function(){return this.add("(?:.*)"),this},anythingBut:function(a){return a=this.sanitize(a),this.add("(?:[^"+a+"]*)"),this},something:function(){return this.add("(?:.+)"),this},somethingBut:function(a){return a=this.sanitize(a),this.add("(?:[^"+a+"]+)"),this},replace:function(a,b){return a=a.toString(),a.replace(this,b)},lineBreak:function(){return this.add("(?:\\r\\n|\\r|\\n)"),this},br:function(){return this.lineBreak()},tab:function(){return this.add("\\t"),this},word:function(){return this.add("\\w+"),this},whitespace:function(){return this.add("\\s"),this},anyOf:function(a){return a=this.sanitize(a),this.add("["+a+"]"),this},any:function(a){return this.anyOf(a)},range:function(){var a,b,c=arguments.length,d=new Array(c/2),e=0,f=0;for(d[e++]="[";c>f;)a=this.sanitize(arguments[f++]),b=this.sanitize(arguments[f++]),d[e++]=a+"-"+b;return d[e++]="]",this.add(d.join("")),this},addModifier:function(a){return-1===this._modifiers.indexOf(a)&&(this._modifiers+=a),this.add(),this},removeModifier:function(a){return this._modifiers=this._modifiers.replace(a,""),this.add(),this},withAnyCase:function(a){return a!==!1?this.addModifier("i"):this.removeModifier("i"),this.add(),this},stopAtFirst:function(a){return a!==!1?this.removeModifier("g"):this.addModifier("g"),this.add(),this},searchOneLine:function(a){return a!==!1?this.removeModifier("m"):this.addModifier("m"),this.add(),this},repeatPrevious:function(){var a,b,c;if(arguments.length<=1)null!==/\d+/.exec(arguments[0])&&(a="{"+arguments[0]+"}");else{for(b=[],c=0;c<arguments.length;c++)null!==/\d+/.exec(arguments[c])&&b.push(arguments[c]);a="{"+b.join(",")+"}"}return this.add(a),this},oneOrMore:function(){return this.add("+"),this},multiple:function(a){return a=a.source||this.sanitize(a),1===arguments.length&&this.add("(?:"+a+")*"),arguments.length>1&&(this.add("(?:"+a+")"),this.add("{"+arguments[1]+"}")),this},or:function(a){return this._prefixes+="(?:",this._suffixes=")"+this._suffixes,this.add(")|(?:"),a&&this.then(a),this},beginCapture:function(){return this._suffixes+=")",this.add("("),this},endCapture:function(){return this._suffixes=this._suffixes.substring(0,this._suffixes.length-1),this.add(")"),this},toRegExp:function(){var a=this.toString().match(/\/(.*)\/([gimuy]+)?/);return new RegExp(a[1],a[2])}},"undefined"!=typeof a.module&&a.module.exports?module.exports=c:"function"==typeof a.define&&a.define.amd?a.define(d,[],function(){return b}):a[d]=c}(this); | ||
!function(a){function b(){var a=new RegExp;return b.injectClassMethods(a),a}function c(){return new b}var d="VerEx";b.injectClassMethods=function(a){var c;for(c in b.prototype)b.prototype.hasOwnProperty(c)&&(a[c]=b.prototype[c]);return a},b.prototype={_prefixes:"",_source:"",_suffixes:"",_modifiers:"gm",sanitize:function(a){var b;return a.source?a.source:"number"==typeof a?a:(b=/([\].|*?+(){}^$\\:=[])/g,a.replace(b,"\\$&"))},add:function(a){return this._source+=a||"",this.compile(this._prefixes+this._source+this._suffixes,this._modifiers),this},startOfLine:function(a){return a=a!==!1,this._prefixes=a?"^":"",this.add(),this},endOfLine:function(a){return a=a!==!1,this._suffixes=a?"$":"",this.add(),this},then:function(a){return a=this.sanitize(a),this.add("(?:"+a+")"),this},find:function(a){return this.then(a)},maybe:function(a){return a=this.sanitize(a),this.add("(?:"+a+")?"),this},anything:function(){return this.add("(?:.*)"),this},anythingBut:function(a){return a=this.sanitize(a),this.add("(?:[^"+a+"]*)"),this},something:function(){return this.add("(?:.+)"),this},somethingBut:function(a){return a=this.sanitize(a),this.add("(?:[^"+a+"]+)"),this},replace:function(a,b){return a=a.toString(),a.replace(this,b)},lineBreak:function(){return this.add("(?:\\r\\n|\\r|\\n)"),this},br:function(){return this.lineBreak()},tab:function(){return this.add("\\t"),this},word:function(){return this.add("\\w+"),this},whitespace:function(){return this.add("\\s"),this},anyOf:function(a){return a=this.sanitize(a),this.add("["+a+"]"),this},any:function(a){return this.anyOf(a)},range:function(){var a,b,c=arguments.length,d=new Array(c/2),e=0,f=0;for(d[e++]="[";c>f;)a=this.sanitize(arguments[f++]),b=this.sanitize(arguments[f++]),d[e++]=a+"-"+b;return d[e++]="]",this.add(d.join("")),this},addModifier:function(a){return-1===this._modifiers.indexOf(a)&&(this._modifiers+=a),this.add(),this},removeModifier:function(a){return this._modifiers=this._modifiers.replace(a,""),this.add(),this},withAnyCase:function(a){return a!==!1?this.addModifier("i"):this.removeModifier("i"),this.add(),this},stopAtFirst:function(a){return a!==!1?this.removeModifier("g"):this.addModifier("g"),this.add(),this},searchOneLine:function(a){return a!==!1?this.removeModifier("m"):this.addModifier("m"),this.add(),this},repeatPrevious:function(){var a,b=/\d+/,c=arguments.length,d=new Array(c),e=0,f=0;for(e=0;c>e;e++)b.test(arguments[e])&&(d[f++]=arguments[e]);return f>0&&(d.length=f,a="{"+d.join(",")+"}"),this.add(a),this},oneOrMore:function(){return this.add("+"),this},multiple:function(a){return a=a.source||this.sanitize(a),1===arguments.length&&this.add("(?:"+a+")*"),arguments.length>1&&(this.add("(?:"+a+")"),this.add("{"+arguments[1]+"}")),this},or:function(a){return this._prefixes+="(?:",this._suffixes=")"+this._suffixes,this.add(")|(?:"),a&&this.then(a),this},beginCapture:function(){return this._suffixes+=")",this.add("("),this},endCapture:function(){return this._suffixes=this._suffixes.substring(0,this._suffixes.length-1),this.add(")"),this},toRegExp:function(){var a=this.toString().match(/\/(.*)\/([gimuy]+)?/);return new RegExp(a[1],a[2])}},"undefined"!=typeof module&&module.exports?module.exports=c:"function"==typeof define&&define.amd?define(d,[],function(){return b}):a[d]=c}(this); | ||
//# sourceMappingURL=verbalexpressions.min.js.map |
@@ -18,3 +18,3 @@ module.exports = function gruntConfig(grunt) { | ||
build: { | ||
src: '<%= pkg.name %>.js', | ||
src: '<%= pkg.main %>', | ||
dest: 'dist/verbalexpressions.js', | ||
@@ -41,3 +41,3 @@ }, | ||
files: { | ||
'dist/verbalexpressions.min.js': ['<%= pkg.name %>.js'], | ||
'dist/verbalexpressions.min.js': ['<%= pkg.main %>'], | ||
}, | ||
@@ -44,0 +44,0 @@ }, |
{ | ||
"name": "verbal-expressions", | ||
"description": "JavaScript Regular expressions made easy", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "regular expressions", |
@@ -1,2 +0,2 @@ | ||
VerbalExpressions v0.2.0 | ||
VerbalExpressions v0.2.1 | ||
===================== | ||
@@ -3,0 +3,0 @@ |
/*! | ||
* VerbalExpressions JavaScript Library v0.2.0 | ||
* VerbalExpressions JavaScript Library v0.2.1 | ||
* https://github.com/VerbalExpressions/JSVerbalExpressions | ||
@@ -46,3 +46,2 @@ * | ||
VerbalExpression.prototype = { | ||
// Variables to hold the whole | ||
@@ -59,2 +58,3 @@ // expression construction in order | ||
var reRegExpEscape; | ||
if (value.source) { | ||
@@ -206,2 +206,3 @@ return value.source; | ||
this.add('[' + value + ']'); | ||
return this; | ||
@@ -397,8 +398,8 @@ }, | ||
// Supports AMD, CommonJS and the browser | ||
if (typeof root.module !== 'undefined' && root.module.exports) { | ||
if (typeof module !== 'undefined' && module.exports) { | ||
// Node.js Module | ||
module.exports = createVerbalExpression; | ||
} else if (typeof root.define === 'function' && root.define.amd) { | ||
} else if (typeof define === 'function' && define.amd) { | ||
// AMD Module | ||
root.define(MODULE_NAME, [], function define() { | ||
define(MODULE_NAME, [], function define() { | ||
return VerbalExpression; | ||
@@ -405,0 +406,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171050