Reputation: 10133
In the following code block, example 10 works as expected. The rg
command matches the given PAT
pattern. But example 11 doesn't match anything. The only difference is the \b
character in the INPUT
variable. What is the reason that example 11 doesn't match?
# example 10:
INPUT="#f/test"
PAT=$(echo "${INPUT}" | sed 's;/;\\/;g')
echo "#f/test line" | rg --vimgrep "${PAT}"
# :1:1:#f/test line
# example 11:
INPUT="#f/test\b"
PAT=$(echo "${INPUT}" | sed 's;/;\\/;g')
echo "#f/test line" | rg --vimgrep "${PAT}"
# (none)
In the next two examples, I omitted sed expression that replaces /
with \/
. Now, word boundary \b
works as expected:
# example 12:
PAT="#f/test"
echo "#f/test line" | rg --vimgrep "${PAT}"
# :1:1:#f/test line
# example 13:
PAT="#f/test\b"
echo "#f/test line" | rg --vimgrep "${PAT}"
# :1:1:#f/test line
What is the reason that word boundary doesn't match in example 11?
Upvotes: 0
Views: 43