Is this the correct way to use byte::Regex? #1246
-
I am refactoring my python code, but there is a problem below. When refactoring using rust, it always fails to match. Can you help me point out where the problem is? python code
rust code
|
Beta Was this translation helpful? Give feedback.
Answered by
BurntSushi
Dec 8, 2024
Replies: 1 comment 1 reply
-
You almost got it. You just need to disable Unicode mode in your pattern. e.g., |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
BurntSushi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You almost got it. You just need to disable Unicode mode in your pattern. e.g.,
(?-u)^blahblah
. Otherwise, things like\xFF
are interpreted as the "the UTF-8 encoding ofU+00FF
," which for non-ASCII codepoints, is different than the raw byte\xFF
. By disabling Unicode mode,\xFF
is interpreted as matching the raw byte\xFF
.