gpt4 book ai didi

regex - 为什么这个带有 2 字节 unicode 字符的正则表达式在匹配时为左值发出 "uninitialized"警告?

转载 作者:行者123 更新时间:2023-12-04 11:41:17 25 4
gpt4 key购买 nike

以下代码:

#!/usr/bin/env perl
use utf8;
use strict;
use warnings;
use 5.012; # implicitly turn on feature unicode_strings
my $test = "some string";
$test =~ m/.+\x{2013}/x;

产量:

Use of uninitialized value $test in pattern match (m//) at test.pl line 9.



这似乎发生在 \x{} 中的任何 2 字节字符中.以下正则表达式工作正常:
/a+\x{2013}/
/.*\x{2013}/
/.+\x{20}/

此外,错误消失了 use bytes ,但使用该编译指示是 discouraged .这里发生了什么?

最佳答案

这是一个错误,现在已通过提交 7e0d5ad7c9cdb21b681e611b888acd41d34c4d05 和
c72077c4fff72b66cdde1621c62fb4fd383ce093。此修复程序应在 5.17.5 中可用

关于regex - 为什么这个带有 2 字节 unicode 字符的正则表达式在匹配时为左值发出 "uninitialized"警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12358714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com