1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-06-25 14:22:54 +02:00

fix word boundary w/ capture group

fixes BurntSushi/ripgrep#506. Word boundary search as arg had unexpected
behavior. added capture group to regex to encapsulate 'or' option search and
prevent expansion and partial boundary finds.

Signed-off-by: Evan.Mattiza <emattiza@gmail.com>
This commit is contained in:
Evan.Mattiza
2017-06-14 22:07:55 -05:00
committed by Andrew Gallant
parent e0989ef13b
commit 06393f888c
2 changed files with 18 additions and 1 deletions

View File

@ -505,7 +505,7 @@ impl<'a> ArgMatches<'a> {
/// flag is set. Otherwise, the pattern is returned unchanged.
fn word_pattern(&self, pat: String) -> String {
if self.is_present("word-regexp") {
format!(r"\b{}\b", pat)
format!(r"\b(?:{})\b", pat)
} else {
pat
}