我想问你如何为下面的代码创建一个模式,找到所有使用字符" Z"并且在有一个数字和字符" _"之后,例如Z133.88_OP0_WELDAIR_FINISH_WALLS
。
这些操作可能就像这样:
G_ZLEVEL_PROFILE_0
ZTEST_OP0_WELDAIR_FINISH_WALLS
Z133.88_OP0_WELDAIR_FINISH_WALLS
Z130.88_OP0_WELDAIR_FINISH_WALLS
Z127.88_OP0_WELDAIR_FINISH_WALLS
Z133.88_OP1_COOLING_FINISH_WALLS
Z130.88_OP1_COOLING_FINISH_WALLS
Z127.88_OP1_COOLING_FINISH_WALLS
我需要它只匹配操作
Z130.88_OP0_WELDAIR_FINISH_WALLS
Z130.88_OP1_COOLING_FINISH_WALLS
Z127.88_OP0_WELDAIR_FINISH_WALLS
Z127.88_OP1_COOLING_FINISH_WALLS
Z133.88_OP0_WELDAIR_FINISH_WALLS
Z133.88_OP1_COOLING_FINISH_WALLS
代码:
pattern = @"(Z\d*)";
foreach (NXOpen.CAM.Operation operation in operations)
{
Match match = Regex.Match(operation.Name, pattern);
if (match.Success)
{
addToCamOperationGroupList(operationName: operation.Name, folderName: match.Groups[1].Value);
}
}