LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI of the Day (08/18/2009)

Now in its new home.  For those of you who haven't ventured over to Breakpoint, I'll repeat the premise of this thread.

 

Reminiscent of the "Word of the Day" calendars, I will choose a function or structure or VI and you can:

 

1) Look at the context help (extra credit for reading detailed help)

2) Use it in a simple VI (use all connectors)

3) Explore the behavior with different inputs, does it accept arrays (1D,2D),  different inputs, try to find interesting behaviors

 

If you are one of those users that have used every function and structure that comes with LV, then feel free to chime in about why a certain item should or should not be useful in our daily lives.  Any gotchas we should be aware of.  Cool tricks?

 

If you are an advanced user, perhaps there are some functions that you haven't had occasion to use, or perhaps there are new ways to solve old problems.

 

If you are a beginner, feel free to post questions/comments.  I hope you learn two things, how to use the context help and perhaps a new VI or two.

 

The function to use today is "Match Pattern" 

 

With the advent (or at least my discovery) of functions such as String to Spreadsheet Array and Scan String for Tokens I use this one a lot less than I used to.  But with the flexibility of the special characters, this is a very versatile function.  For example, you can easily separate a number at the decimal point:

 

MatchPattern.png 

 

(Hint for newbies to this thread:  I am probably trying to trick you) 

Message Edited by Darin.K on 08-18-2009 10:00 AM
Message Edited by Darin.K on 08-18-2009 10:01 AM
Message 1 of 6
(3,354 Views)

Let see who can spot the issue with that code. Smiley Wink

 

See also here for an old Nugget that mentions a code construct that could increase searches for string patterns by a factor of 8 (in older version of LV).

 

Ben

Message Edited by Ben on 08-18-2009 10:36 AM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 6
(3,325 Views)

Hmm, that gives a strange result.

Using a period for the match:

 

string.PNG

 

Using a different character:

 

string2.PNG

 

The second case is generally the expected result.

To be honest, I dont know why it does that Smiley Surprised

My only guess is the fact that it is a period.

 

When you search for abc*, it treats the asterisk as "any other characters".

Maybe the period is being treated in the same way?

So the first character will be treated as the match?

Message Edited by Cory K on 08-18-2009 11:51 AM
Cory K
Message 3 of 6
(3,281 Views)

After you read the detailed help it makes perfect sense, right?  Smiley Wink

 

Unless you happen to be one of about three people, I'll bet you would have made the same mistake the first time.... 

0 Kudos
Message 4 of 6
(3,272 Views)

That's why someone wrote a "detailed help"

 

SNAG-001.jpg

This is the correct syntax for the "match string"

 

 

Edit: I was coding while Darin was typing 🙂

 

Message Edited by Alain S on 08-18-2009 06:59 PM
Message 5 of 6
(3,271 Views)

This should give some insight into the website named Slashdot...

 

slashdot.png

 

It's also worth noting, in the Advanced Help, that Match Regular Expression uses a larger subsut of regular expressions but is slower than Match Pattern.

Message Edited by jcarmody on 08-18-2009 05:31 PM
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

0 Kudos
Message 6 of 6
(3,230 Views)