gpt4 book ai didi

regex - 我不明白为什么这个正则表达式总是返回 false?

转载 作者:行者123 更新时间:2023-12-02 21:42:38 24 4
gpt4 key购买 nike

好的,这是正则表达式:

Match CMD = Regex.Match(CommandString, @"\(([a-z0-9]+);(INTEGER|DECIMAL|STRING);(d{1,3});(((YES|NO);){3})([a-z0-9]+)\)", RegexOptions.IgnoreCase);

if (CMD.Success){
return true;
}
return false;

以下模式应返回 true:

(ID;Integer;12;YES;YES;YES;0)

(weak;String;5;NO;YES;YES;super)

(fabris345;decimal;23;YES;YES;YES;0)

(expr12nd;String;455;NO;YES;NO;super1000)

但它们总是返回 false。为什么?

最佳答案

...(d{1,3})...应该是 (\d{1,3})

关于regex - 我不明白为什么这个正则表达式总是返回 false?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20088891/

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