LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

De-Rube my code please Reg Expression maybe?

Solved!
Go to solution

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 Kudos
Message 1 of 7
(3,824 Views)

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...

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

Message 2 of 7
(3,796 Views)

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

Message 3 of 7
(3,779 Views)

The following will also work.

 

Ben64

 

regex solution.png

Message 4 of 7
(3,765 Views)
Solution
Accepted by topic author 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

Message 5 of 7
(3,744 Views)

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 Kudos
Message 6 of 7
(3,740 Views)

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>

Message 7 of 7
(3,711 Views)