Skip to content

essentialib/pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pattern

Easy handling of JavaScript regular expressions.

install & import

npm install @essentialib/pattern
const Pattern = require("@essentialib/pattern");

example

// same as /-?(\d+)/
const isInteger = Pattern(_ => _
    .maybe('-')  
    .capture(g1 => g1
        .digit().oneOrMore()
    )
);

console.log(isInteger.test('-34'));  // true

See the wiki for more information