Package Exports
- xspattern
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xspattern) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
xspattern.js
XML Schema Regular Expression engine
This library implements a regular expression engine for the regular expression language defined in XML Schema 1.0 and 1.1. It follows the XML Schema 1.1 specification, which corrects some errors in earlier versions but is otherwise fully compatible.
Installation
The xspattern library can be installed using npm or yarn:
npm install --save xspattern
or
yarn add xspattern
The package includes both a CommonJS bundle (dist/xspattern.js
) and an ES6
module (dist/xspattern.mjs
).
Usage
The library currently exports a single function compile
, which expects a
string containing a single pattern and returns a function. This function
accepts a single string representing a value to test and returns a boolean
indicating whether the value matches the pattern.
// for ES6 / Typescript:
import { compile } from 'xspattern';
// or for CommonJS / Node.js:
const { compile } = require('xspattern');
// This pattern matches sequences of one or more lower case consonants
const matchesPattern = compile('[a-z-[aeoui]]+');
console.log(matchesPattern('asdfgh')); // false
console.log(matchesPattern('zxcvbn')); // true