Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex support for matching a value #39

Open
joeworkman opened this issue Jul 25, 2018 · 1 comment
Open

Regex support for matching a value #39

joeworkman opened this issue Jul 25, 2018 · 1 comment

Comments

@joeworkman
Copy link

It would be interesting to have a way of using regular expressions inside of the query statements.

@deitch
Copy link
Owner

deitch commented Jul 27, 2018

It isn't that hard. The search object is, well, a JS object, which means that it can include any valid JS type: string, number, boolean, but also Date (already supports it) and regex. You could do

{name: /john/I}

We already have some partial regex support implemented.

  • When you set _text, it matches any part of the word.
  • If the field is a string, it ignores case
  • If you set _start, it matches the beginning of the word
  • If you set _end, it matches the end of the word

It actually does the above using RegExp internally, see here

Definitely open for a PR for that. Just needs:

  • test cases (probably could use the data already in test and more cases)
  • README
  • code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants