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/testb"
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/testb"
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?