How to express the -w
option in a regular expression string?
#1733
-
I have a sample like this, the word
I can use
But somehow I can't use options, I can only use regular expression strings, so i use command
How to express the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Good question! Why are you using the raw UTF-8 encoding like that? When you use Firstly, with the
Similarly, without the
If you want to continue using the raw UTF-8 encoding for some reason, then you may do so, but only disable Unicode around the portion of the regex that is matching raw bytes:
And finally, for completeness, note that the |
Beta Was this translation helpful? Give feedback.
-
Thanks, this is very helpful. |
Beta Was this translation helpful? Give feedback.
Good question!
Why are you using the raw UTF-8 encoding like that? When you use
\b
when Unicode mode is disabled, then it's an ASCII word boundary, not a Unicode word boundary. So it will not work correctly with text that is not ASCII.Firstly, with the
-w
flag, you can invoke ripgrep with your Chinese characters directly:Similarly, without the
-w
flag:If you want to continue using the raw UTF-8 encoding for some reason, then you may do so, but only disable Unicode around the portion of the regex that is matching raw bytes: