LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to eliminate lines from string

Solved!
Go to solution

Hey Guys 

I am controlling a setup that i built using labview. It is governed by a QSM that can read to commands from a text file. I inherited some code that reads a text file of the format "Some Command;", but this code requires  that i only have commands in the text file that also end with ";".  I have to write the text file manually so it would be nice to make it a bit more comprehendable. So added names and to identify those i use the ":" i can then remove them by using search and replace. But what how can i remove wite space or generic text like in the file that i attached?

also is there an easy way to make a command that also imports a value like "command, value =4" and then read the 4?

i hope you can help.

Atamsih

Download All
0 Kudos
Message 1 of 19
(4,725 Views)

You can use regular expression to filter what you want.

 

remove lines.png

 

Ben64

0 Kudos
Message 2 of 19
(4,713 Views)
Solution
Accepted by topic author Atamsih
Message 3 of 19
(4,697 Views)

@Atamsih wrote:

[...]
also is there an easy way to make a command that also imports a value like "command, value =4" and then read the 4?

[...]


 

 

Here's a quick pass at this request, using Match Regular Expression:

 

Example_VI_BD.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 4 of 19
(4,686 Views)

Darin.K,

 

Can you explain "([^\v;]*)(?<!; )(\z|\v)" to people like myself who aren't familiar with it.  Even after reading the documentation I am confused by this notation.

 

-SS



0 Kudos
Message 5 of 19
(4,673 Views)

ShotSimon wrote:

Can you explain "([^\v;]*)(?<!; )(\z|\v)" to people like myself who aren't familiar with it.  Even after reading the documentation I am confused by this notation.


Don't you wish there was a graphical way to compose regular expressions. 😄

Message 6 of 19
(4,640 Views)

@altenbach wrote:

Don't you wish there was a graphical way to compose regular expressions. 😄


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

 


ShotSimon wrote:

Can you explain "([^\v;]*)(?<!; )(\z|\v)" to people like myself who aren't familiar with it.  Even after reading the documentation I am confused by this notation.


Big Picture:  look for lines which do not end in ';' these will be replaced by empty strings

 

([^\v;]*) : grab characters 0 or more characters which are not vertical whitespace or ;

(?<!; ) : negative lookbehind for ; (keeps newline for lines ending in ; )  [this is tricky] [can be removed if you want a ';' delimited list]

(\z|\v) : grab the newline or end of string not preceded by a ';'

 

It takes a while to go from 'hocus pocus' to 'easy peasy'

 

Edit: Lithium thinks I wink a lot when I try to enter these regexes.  Smiley Mad  and yes I mean Smiley Mad

 

Message 7 of 19
(4,631 Views)

@Darin.K wrote:
([^\v;]*) : grab characters 0 or more characters which are not vertical whitespace or ;

One of the problems is for example that "\v" is not listed in the LabVIEW documentation.

 

 

Message 8 of 19
(4,624 Views)
The Match Regular Expression function in LabVIEW supports perl-compatible regular expressions (PCRE). The full syntax for PCRE is very large and complex, and it supports many obscure features that most users will never need. As a result we deliberately chose not to document the full set of features supported by the syntax. If we had done that we would have ended up with a very large document that is difficult to maintain and simply overwhelming for the majority of users (a counterproductive result). Instead we chose to document only the most important and commonly used parts of the syntax. We did, however, include the address of the website hosting the full documentation: www.pcre.org (see the note right above the table). This website hosts the open source library which we use to do the matching, and also includes documentation for every feature supported by the syntax. Specifically it links to two documents: 1. The "man page" (UNIX documentation) for the library (including syntax): http://pcre.org/pcre.txt 2. The perl 5 documentation for regular expressions: http://perldoc.perl.org/perlre.html As I said, those documents are large and overwhelming for most users, and we did not want that to be the experience for our users, nor did we want to have to maintain a document like that which would be at best redundant, and at worst possibly include mistakes. We thought it best to just outline the important features and link to the complete documentation. I hope this helps.
0 Kudos
Message 9 of 19
(4,584 Views)
FYI, I did file CAR #383692 to make the reference to pcre.org more prominent and suggested that it be a clickable link. Maybe that will help people more in the future.
Message 10 of 19
(4,582 Views)