-6

maya ascii 文件包含如下指令行。

...
createNode transform -n "pCylinder1";
createNode mesh -n "pCylinderShape1" -p "pCylinder1";
    setAttr ".vif" yes;
    setAttr ".uvst[0].uvsn" -type "string" "map1";
createNode transform -n "pPlane1";
    setAttr ".t" -type "double3" 7.3666236108700112 0 -4.2288466031573595 ;
createNode mesh -n "pPlaneShape1" -p "pPlane1";
    setAttr ".uvst[0].uvsn" -type "string" "map1";
    setAttr ".cuvs" -type "string" "map1";
createNode transform -n "pTorus1";
    setAttr ".t" -type "double3" -0.47688973199150198 0 -10.843417358550912 ;
...
connectAttr "polySphere1.out" "pSphereShape1.i";
connectAttr "polyCube1.out" "pCubeShape1.i";
connectAttr "polyCylinder1.out" "pCylinderShape1.i";
connectAttr "polyPlane1.out" "pPlaneShape1.i";
connectAttr "polyTorus1.out" "pTorusShape1.i";

...

在这些行中,我需要搜索一条看起来像以下任何行的行。

createNode transform -n nodeName -p "FG";
createNode transform -n nodeName -p "BG";
createNode transform -n nodeName -p "MG";

我应该使用什么正则表达式来查找上述任何内容。

4

1 回答 1

1

这是我可以对您的描述做的最好的事情:

我需要将搜索结果(可能是 FG|BG|MG )与已知字符串连接起来

import re

line = "createNode transform -n \"water\" -p \"FG\";" 

m = search(r'(FG|BG|MG)',line)
if m:
    result = m.groups()[0]

    # What do you want to concat it to? 
    known_string = "known_string" + result

“现在我需要搜索这个字符串。为什么?你已经搜索过了。
“zam 未知- 不,它不是,它是re.compile()

抱歉,我无法进一步了解您的描述

于 2012-05-19T08:50:13.583 回答