Skip to content

A tiny project to convert boolean query string to regular expressions

License

Notifications You must be signed in to change notification settings

nqkdev/lucene-to-regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lucene to Regex for Javascript

Build Status npm

This tiny project provides ability to convert a boolean query string to regular expressions.

Installation

npm install --save lucene-to-regex

Usage

const ltr = require('lucene-to-regex')
const regex = ltr.toRegex('Lucene AND Regex AND (easy NOT difficult)', 'i')
// regex: /^(?=.*?\bLucene\b)(?=.*?\bRegex\b)(?=.*?(?=.*?\beasy\b)(?!.*?\bdifficult\b)).*$/i


regex.test('Regex and Lucene are easy.')
// result: true

regex.test('Lucene and regex are difficult.')
// result: false

You can set flag by passing an additional parameter to the method.

Check out bripkens/lucene for lucene

About

A tiny project to convert boolean query string to regular expressions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published