Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

verbal-expressions

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

verbal-expressions - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

bower.json

2

Gruntfile.js

@@ -8,5 +8,5 @@ module.exports = function(grunt) {

grunt.loadNpmTasks("grunt-contrib-qunit");
grunt.loadNpmTasks("grunt-contrib-qunit");
grunt.registerTask('test', 'qunit');
grunt.registerTask('default', ['qunit']);
};
{
"name": "verbal-expressions",
"description": "JavaScript Regular expressions made easy",
"version": "0.1.1",
"version": "0.1.2",
"keywords": [ "regular expressions", "regex" ],
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-qunit": "~0.2.2"

@@ -11,6 +12,6 @@ },

"type": "git",
"url": "git://github.com/jehna/VerbalExpressions.git"
"url": "git://github.com/VerbalExpressions/JSVerbalExpressions.git"
},
"bugs": {
"url": "https://github.com/jehna/VerbalExpressions/issues"
"url": "https://github.com/VerbalExpressions/JSVerbalExpressions/issues"
},

@@ -17,0 +18,0 @@ "main": "VerbalExpressions.js",

@@ -1,2 +0,2 @@

VerbalExpressions v0.1.1
VerbalExpressions v0.1.2
=====================

@@ -3,0 +3,0 @@

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ test( "something", function() {

/*!
* VerbalExpressions JavaScript Library v0.1
* https://github.com/jehna/VerbalExpressions
* VerbalExpressions JavaScript Library v0.1.2
* https://github.com/VerbalExpressions/JSVerbalExpressions
*

@@ -10,3 +10,3 @@ *

* Date: 2013-07-19
*
*
*/

@@ -17,3 +17,3 @@

var root = this;
var root = this;

@@ -23,3 +23,3 @@ // I am the constructor function.

var verbalExpression = new RegExp();
// Add all the class methods

@@ -29,29 +29,29 @@ VerbalExpression.injectClassMethods( verbalExpression );

// Return the new object.
return( verbalExpression );
return verbalExpression;
}
// Define the static methods.
VerbalExpression.injectClassMethods = function( verbalExpression ){
// Loop over all the prototype methods
for (var method in VerbalExpression.prototype){
// Make sure this is a local method.
if (VerbalExpression.prototype.hasOwnProperty( method )){
// Add the method
verbalExpression[ method ] = VerbalExpression.prototype[ method ];
}
}
return( verbalExpression );
return verbalExpression;
};
// Define the class methods.
VerbalExpression.prototype = {
// Variables to hold the whole

@@ -63,4 +63,4 @@ // expression construction in order

_modifiers : "gm", // default to global multiline matching
// Sanitation function for adding

@@ -70,5 +70,6 @@ // anything safely to the expression

if(value.source) return value.source;
return value.replace( /[\\^$|()\[\]{}.*+?]/g, "\\$&" );
if(typeof value === "number") return value;
return value.replace(/[^\w]/g, function(character) { return "\\" + character; });
},
// Function to add stuff to the

@@ -81,20 +82,20 @@ // expression. Also compiles the

this.compile(this._prefixes + this._source + this._suffixes, this._modifiers);
return( this );
return this;
},
// Start and end of line functions
startOfLine: function( enable ) {
enable = ( enable != false );
enable = ( enable !== false );
this._prefixes = enable ? "^" : "";
this.add( "" );
return( this );
return this;
},
endOfLine : function( enable ) {
enable = ( enable != false );
enable = ( enable !== false );
this._suffixes = enable ? "$" : "";
this.add( "" );
return( this );
return this;
},
// We try to keep the syntax as

@@ -108,5 +109,5 @@ // user-friendly as possible.

this.add( "(?:" + value + ")" );
return( this );
return this;
},
// And because we can't start with

@@ -117,5 +118,5 @@ // "then" function, we create an alias

find : function( value ) {
return( this.then( value ) );
return this.then( value );
},
// Maybe is used to add values with ?

@@ -125,11 +126,11 @@ maybe : function( value ) {

this.add( "(?:" + value + ")?" );
return( this );
return this;
},
// Any character any number of times
anything : function() {
this.add( "(?:.*)" );
return( this );
return this;
},
// Anything but these characters

@@ -139,3 +140,3 @@ anythingBut : function( value ) {

this.add( "(?:[^" + value + "]*)" );
return( this );
return this;
},

@@ -146,3 +147,3 @@

this.add( "(?:.+)" );
return( this );
return this;
},

@@ -154,3 +155,3 @@

this.add( "(?:[^" + value + "]+)" );
return( this );
return this;
},

@@ -167,11 +168,11 @@

},
/// Add regular expression special ///
/// characters ///
// Line break
lineBreak : function() {
this.add( "(?:(?:\\n)|(?:\\r\\n))" ); // Unix + windows CLRF
return( this );
this.add( "(?:\\r\\n|\\r|\\n)" ); // Unix + windows CLRF
return this;
},

@@ -182,15 +183,15 @@ // And a shorthand for html-minded

},
// Tab (duh?)
tab : function() {
this.add( "\\t" );
return( this );
return this;
},
// Any alphanumeric
word : function() {
this.add( "\\w+" );
return( this );
return this;
},
// Any given character

@@ -200,30 +201,30 @@ anyOf : function( value ) {

this.add( "["+ value +"]" );
return( this );
return this;
},
// Shorthand
any : function( value ) {
return( this.anyOf( value ) );
return this.anyOf( value );
},
// Usage: .range( from, to [, from, to ... ] )
range : function() {
var value = "[";
for(var _to = 1; _to < arguments.length; _to += 2) {
var from = this.sanitize( arguments[_to - 1] );
var from = this.sanitize( arguments[_to - 1] );
var to = this.sanitize( arguments[_to] );
value += from + "-" + to;
}
value += "]";
this.add( value );
return( this );
return this;
},
/// Modifiers ///
// Modifier abstraction

@@ -235,3 +236,3 @@ addModifier : function( modifier ) {

this.add("");
return( this );
return this;
},

@@ -241,16 +242,16 @@ removeModifier : function( modifier ) {

this.add("");
return( this );
return this;
},
// Case-insensitivity modifier
withAnyCase : function( enable ) {
if(enable != false) this.addModifier( "i" );
if(enable !== false) this.addModifier( "i" );
else this.removeModifier( "i" );
this.add( "" );
return( this );
return this;
},
// Default behaviour is with "g" modifier,

@@ -260,29 +261,30 @@ // so we can turn this another way around

stopAtFirst : function( enable ) {
if(enable != false) this.removeModifier( "g" );
if(enable !== false) this.removeModifier( "g" );
else this.addModifier( "g" );
this.add( "" );
return( this );
return this;
},
// Multiline, also reversed
searchOneLine : function( enable ) {
if(enable != false) this.removeModifier( "m" );
if(enable !== false) this.removeModifier( "m" );
else this.addModifier( "m" );
this.add( "" );
return( this );
return this;
},
// Repeats the previous item
// Repeats the previous item
// exactly n times or
// between n and m times.
repeatPrevious: function( ) {
var value;
if(arguments.length <= 1) {
if(/\d+/.exec(arguments[0]) != null) {
var value = "{" + arguments[0] + "}";
if(/\d+/.exec(arguments[0]) !== null) {
value = "{" + arguments[0] + "}";
}

@@ -292,8 +294,8 @@ } else {

for(var i=0; i< arguments.length; i++) {
if(/\d+/.exec(arguments[i]) != null) {
values.push(arguments[i])
}
if(/\d+/.exec(arguments[i]) !== null) {
values.push(arguments[i]);
}
}
var value = "{" + values.join(",") + "}";
value = "{" + values.join(",") + "}";
}

@@ -304,7 +306,7 @@

},
/// Loops ///
multiple : function( value ) {

@@ -321,15 +323,15 @@ // Use expression or string

}
return( this );
return this;
},
// Adds alternative expressions
or : function( value ) {
this._prefixes += "(?:";
this._suffixes = ")" + this._suffixes;
this.add( ")|(?:" );
if(value) this.then( value );
return( this );
return this;
},

@@ -343,3 +345,3 @@

return( this );
return this;
},

@@ -352,4 +354,4 @@

this.add( ")", true );
return( this );
return this;
},

@@ -362,3 +364,3 @@

}
};

@@ -380,3 +382,3 @@

}
}).call();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc