New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-regexp

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-regexp

New RegExp Style for Node.js

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

node-regexp

New RegExp Style for Node.js

Install

$ npm install node-regexp

API

Methods

var regexp = require('node-regexp')
var re = regexp().
  .start('str')        // must start str
  .maybe('str')        // maybe match str
  .atleast(3)          // atleast match 3 times
  .must('str')         // must match str
  .has(1, 5)           // should have 1 to 5
  .either('str1', 'str2', 'str3') // either str1, str2, str3
  .find('str')         // capture match
  .anythingBut('str')  // anything match but str
  .somethingBut('str') // something match but str
  .end('str')          // match end str
  .global()            // global match
  .ignoreCase()        // ignore case match
  .multiline()         // multiple lines match
  .toRegExp()          // return a RegExp
  .toString()          // return a String

Vars

var regexp = require('node-regexp')
regexp.number = "[0-9]"
regexp.lower = "[a-z]"
regexp.upper = "[A-Z]"
regexp.letter = "[a-zA-Z]"
regexp.tab = "\\t"
regexp.space = "\\s"
regexp.word = "\\w"
regexp.digit = "\\d"
regexp.newline = "\\n"
regexp.return = "\\r"
regexp.eol = "(?:(?:\\n)|(?:\\r\\n))"

Demo

var regexp = require('node-regexp')
var re = regexp()
  .start('http')
  .maybe('s')
  .must('://')
  .maybe('WWW.')
  .somethingBut(regexp.space)
  .end('.com')
  .ignoreCase()
  .toRegExp()

re.test("http://qq.com") // => true
re.test("http://www.qq.com") // => true
re.test("https://www.qq.com") // => true
re.test("http://www.qqcom") // => false
re.test("https://www.qq.net") // => false

FAQs

Package last updated on 14 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts