Skip to content

Commit 27241fd

Browse files
authored
fix #13528 nimgrep --word now works better with operators (#13537)
1 parent 05e9473 commit 27241fd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/nimgrep.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,8 @@ else:
649649
if optIgnoreStyle in options:
650650
pattern = styleInsensitive(pattern)
651651
if optWord in options:
652-
pattern = r"\b(:?" & pattern & r")\b"
652+
# see https://github.com/nim-lang/Nim/issues/13528#issuecomment-592786443
653+
pattern = r"(^|\W)(:?" & pattern & r")($|\W)"
653654
if {optIgnoreCase, optIgnoreStyle} * options != {}:
654655
reflags.incl reIgnoreCase
655656
let rep = if optRex in options: rex(pattern, reflags)

0 commit comments

Comments
 (0)