英文:
what does `too short multibyte code string in regex` mean?
问题
我正在创建一个Sublime Text的语法高亮文件。然而,我遇到了一个我不太理解的错误。我有以下的正则表达式:
\x([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])
当我尝试在Sublime Text中加载这个文件时,我得到了以下错误:
> Error in regex: too short multibyte code string in regex
> \x([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])
我尝试通过谷歌搜索来理解这个错误的含义,但我只找到了以下相关的链接:
不幸的是,从这些链接中我只能确定这个错误很可能是由字符编码引起的[来自1和2]。我现在怀疑"\x"可能是问题所在,因为正则表达式中的其他部分都是正确的。如何转义这个字符和其他类似的字符?特别地,是否可以使用一个Golang脚本来清理正则表达式以解决这些问题?
英文:
I am creating a sublime text highlighting file. However, I am stuck with an error I don't fully understand. I have the following regex:
\x([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])
When I try to load the file in sublime text, I get the error:
> Error in regex: too short multibyte code string in regex
> \x([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])
I have tried Googling to understand what this error means, the only thing I have come across that is relavent are the following links:
0. github issue of the rubinius project
Unfortunately, from those links i could only determine that that error likely caused by a character encoding [ from 1 & 2]. I now suspect that "\x" might be the problem as everything else in that regex is fine. How does one escape that character and all others like it, in particular, can a golang script be used to sanitize regexes to get rid of such problems?
答案1
得分: 3
这意味着你忘记在\x
中转义\
了。
因此,它试图解析形式为\x1234
的 Unicode 字符转义,但没有找到足够的数字。
英文:
It means that you forgot to escape the \
in \x
.
Therefore, it's trying to parse a Unicode character escape of the form \x1234
, and it didn't find enough numbers.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论