noprompt / frak

Transform collections of strings into regular expressions.
1.13k stars 39 forks source link

Add whole-words? option for generated patterns to match only whole words #15

Closed joelittlejohn closed 7 years ago

joelittlejohn commented 7 years ago

This option causes patterns to require a word boundary on either end of the match. For instance a pattern built like:

(frak/pattern ["foo" "bar" "baz"] {:whole-words? true})

Will create a match against the following strings:

"foo is a metasyntactic variable"
"sometimes we use baz"

but will not create a match against the following:

"food and nutrition"
"clubs and bars"
noprompt commented 7 years ago

Sorry for the late response! I like this. If you could address the two small issues I referenced in the code I'll get this merged. If you're busy I can address it myself a little later. Thanks!

joelittlejohn commented 7 years ago

Great, thanks for looking at this Joel! I've addressed the comments. Any other suggestions please shout. Glad to be able to contribute to this fantastic library.

noprompt commented 7 years ago

@joelittlejohn I've pushed a new release. It's been a long time since I've built this project so let me know if there are any issues.

joelittlejohn commented 7 years ago

@noprompt brilliant, thanks!

joelittlejohn commented 7 years ago

I've integrated the latest version in a project I'm working on and everything looks good :+1: