取消
显示结果 
搜索替代 
您的意思是: 

De-Rube my code please Reg Expression maybe?

已解决!
转到解答

Hi All!

 

I will avoid text based solutions but after looking at my code, I thought I may get a chance to learn a better way to do this.

 

Problem:

In LV 8.6 there is an issue where a particular "node' in a VRML file will result in LV crashing if I attempt to open a file that contained that node.

 

Solution:

Wirte code to check the file and remove the bad "node" beforea attempting to open it.

 

SO this code works but screams "Could this be done better using Reg Expresions?"

 

Rube.PNG

 

I think the picture tells the rest of the story.

 

NOTE: The non-visalbe cases just pass the wires through.

 

SO share your thoughts please.

 

Ben 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 项奖励
1 条消息(共 7 条)
4,256 次查看

I'm not the regex guy, but this topic looks like it should at least be cross-referenced in the "Regular Expresions Board" topic.

 

http://forums.ni.com/t5/BreakPoint/Regular-Expressions-Board/td-p/1187799

 

I just tweeted about this topic because of a post on LAVA regarding using regex to process HTML. It seems regex is popular lately...

 

2 条消息(共 7 条)
4,228 次查看

Read this regex like:

 

  • find literal string "color Color {" followed by a line feed
  • next line must be the literal string "color [" followed by a line feed
  • the next lines can contain anything (followed by a line feed)
  • the next to last line must be a literal "]" followed by a line feed
  • the last line must be a literal "}" followed by a line feed

 

ben.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

3 条消息(共 7 条)
4,211 次查看

The following will also work.

 

Ben64

 

regex solution.png

4 条消息(共 7 条)
4,197 次查看
解答
已被主题作者 Ben 接受

Even better than my original.  This one finds the beginning of the selection followed byeverything up to the first "}" (and line feed).

 

ben_BD.png

 

Kudos to ben64 for the hint.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

5 条消息(共 7 条)
4,176 次查看

My Rube reduced to 22 characters...

 

Where is that embarased emoticon?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 项奖励
6 条消息(共 7 条)
4,172 次查看

First, it is great that you are going to use Search and Replace with Regular Expression selected and not some string gymnastics to remove those sections.

 

<plug type="shameless">

Second, if you are looking to hone your regex skills without having to memorize a bunch of special codes, check out the example I posted for the current contest.

 

http://decibel.ni.com/content/docs/DOC-13698

 

</plug>

7 条消息(共 7 条)
4,143 次查看