https://github.com/nqkdev/lucene-to-regex
A tiny project to convert boolean query string to regular expressions
https://github.com/nqkdev/lucene-to-regex
boolean-query lucene lucene-query regex
Last synced: 5 months ago
JSON representation
A tiny project to convert boolean query string to regular expressions
- Host: GitHub
- URL: https://github.com/nqkdev/lucene-to-regex
- Owner: nqkdev
- License: mit
- Created: 2017-10-11T19:00:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-11-20T18:52:00.000Z (over 5 years ago)
- Last Synced: 2025-11-27T09:07:59.213Z (7 months ago)
- Topics: boolean-query, lucene, lucene-query, regex
- Language: JavaScript
- Size: 17.6 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lucene to Regex for Javascript
[](https://travis-ci.org/nqkdev/lucene-to-regex)
[]()
This tiny project provides ability to convert a boolean query string to regular expressions.
### Installation
```bash
npm install --save lucene-to-regex
```
### Usage
```js
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](https://github.com/bripkens/lucene) for lucene