首页 新闻 搜索 专区 学院

正则表达式问题

0
悬赏园豆:10 [已解决问题] 解决于 2015-09-21 14:39

需要匹配的字符串如下:

#VRML V2.0 utf8

# Generated by VCGLIB, (C)Copyright 1999-2001 VCG, IEI-CNR

NavigationInfo {
    type [ "EXAMINE", "ANY" ]
}
DEF Box01 Transform {
  scale 1 1 1
  translation 0 0 0
  children
  [
    Shape
    {
      geometry IndexedFaceSet
      {
        creaseAngle .5
        solid FALSE
        coord Coordinate
        {
          point
          [
            948.701 665.378 288.971, 948.204 665.874 259.231, 948.699 671.327 289.469, 948.203 671.32 259.229
          ]
        }
        color Color
        {
          color
          [
            0.690196 0.345098 0.101961, 0.690196 0.345098 0.101961, 0.690196 0.345098 0.101961, 0.690196 0.345098 0.101961
          ]
        }
        coordIndex
        [
          9,13,3,-1, 3,1,9,-1, 16,18,22,-1, 22,20,16,-1, 0,11,19,-1, 19,4,0,-1
        ]
      }
      appearance Appearance
      {
        material Material
        {
           ambientIntensity 0.2
           diffuseColor 0.9 0.9 0.9
           specularColor .1 .1 .1
           shininess .5
        }
      }
    }
  ]
}

DEF Box02 Transform {
  scale 1 1 1
  translation 0 0 0
  children
  [
    Shape
    {
      geometry IndexedFaceSet
      {
        creaseAngle .5
        solid FALSE
        coord Coordinate
        {
          point
          [
            948.701 665.378 288.971, 948.204 665.874 259.231, 948.699 671.327 289.469, 948.203 671.32 259.229
          ]
        }
        color Color
        {
          color
          [
            0.690196 0.345098 0.101961, 0.690196 0.345098 0.101961, 0.690196 0.345098 0.101961, 0.690196 0.345098 0.101961
          ]
        }
        coordIndex
        [
          9,13,3,-1, 3,1,9,-1, 16,18,22,-1, 22,20,16,-1, 0,11,19,-1, 19,4,0,-1
        ]
      }
      appearance Appearance
      {
        material Material
        {
           ambientIntensity 0.2
           diffuseColor 0.9 0.9 0.9
           specularColor .1 .1 .1
           shininess .5
        }
      }
    }
  ]
}

DEF Box03 Transform {
  scale 1 1 1
  translation 0 0 0
  children
  [
    Shape
    {
      geometry IndexedFaceSet
      {
        creaseAngle .5
        solid FALSE
        coord Coordinate
        {
          point
          [
            948.701 665.378 288.971, 948.204 665.874 259.231, 948.699 671.327 289.469, 948.203 671.32 259.229
          ]
        }
        color Color
        {
          color
          [
            0.690196 0.345098 0.101961, 0.690196 0.345098 0.101961, 0.690196 0.345098 0.101961, 0.690196 0.345098 0.101961
          ]
        }
        coordIndex
        [
          9,13,3,-1, 3,1,9,-1, 16,18,22,-1, 22,20,16,-1, 0,11,19,-1, 19,4,0,-1
        ]
      }
      appearance Appearance
      {
        material Material
        {
           ambientIntensity 0.2
           diffuseColor 0.9 0.9 0.9
           specularColor .1 .1 .1
           shininess .5
        }
      }
    }
  ]
}

 

写一个正则表达式获取所有的 Transform节点和Transform节点中的全部内容

  Transform {
  scale 1 1 1
  translation 0 0 0
  children
  [

  .................

  ]

}

E1ement的主页 E1ement | 初学一级 | 园豆:59
提问于:2015-09-18 16:57
< >
分享
最佳答案
0

DEF[\s\S]+?(Transform[\s\S]+?)DEF

收获园豆:8
湖底的鱼 | 初学一级 |园豆:10 | 2015-09-18 17:31

首先非常感谢你的指点,有的没有DEF Box02这种别名定义,直接Transform开头,如何修改下?

E1ement | 园豆:59 (初学一级) | 2015-09-18 17:38

@E1ement: (Transform[\s\S]+?)(DEF|Transform)

湖底的鱼 | 园豆:10 (初学一级) | 2015-09-18 21:20

@湖底的鱼: 谢谢

E1ement | 园豆:59 (初学一级) | 2015-09-21 14:37
其他回答(1)
0

Transform {[\s\S]*?children[[\s\S]*?]\s*}(?=(\s*DEF|$))  试试

收获园豆:2
clarlespeng | 园豆:469 (菜鸟二级) | 2015-09-18 17:33

谢谢

支持(0) 反对(0) E1ement | 园豆:59 (初学一级) | 2015-09-21 14:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册