任何人都可以帮助这个脚本,我只是凡人而不是程序员!只有第一个字符串表达式正在工作
目标是获取具有以下邮政编码范围的订单,以将自己分配到文件夹 7000-8999 3000-3999 5000-5900
String AusPostcodeExp = @"^[78][0-9][0-9][0-9]$";
String AusPostcodeExp2 = @"^3[0-9][0-9][0-9]$";
String AusPostcodeExp3 = @"^5[0-8][0-9][0-9]$";
String AusPostcodeExp4 = @"^5[0-9][0][0]$";
String postcode = order.PostCode.ToString();
if (order.Country.ToUpper() == "AUSTRALIA" && IsValid(postcode, AusPostcodeExp ))
if (order.Country.ToUpper() == "AUSTRALIA" && IsValid(postcode, AusPostcodeExp2 ))
if (order.Country.ToUpper() == "AUSTRALIA" && IsValid(postcode, AusPostcodeExp3 ))
if (order.Country.ToUpper() == "AUSTRALIA" && IsValid(postcode, AusPostcodeExp4 ))
{
order.SetAssignToAFolder("MELBOURNE");
答案 0 :(得分:0)
您可以使用替换(|
)。例如,A|B
将首先尝试匹配模式A
,如果失败,则会尝试匹配模式B
。
您可以将此与其他正则表达式构造(如组((…)
)和量词({…}
)结合使用,以显着简化您的模式。
尝试这样的模式:
^([378][0-9]{3}|5([0-8][0-9]{2}|900))$
希望这个图表(使用Regexper生成)将有助于解释这里发生的事情: