ni.com is currently experiencing slowness/issues due to ongoing maintenance.
Support teams are actively working on the soonest resolution.
ni.com is currently experiencing slowness/issues due to ongoing maintenance.
Support teams are actively working on the soonest resolution.
07-20-2010 07:15 AM - edited 07-20-2010 07:15 AM
We have an excel board. Should we have a repository for regular expressions too. This might be just and useful as the Excel board.
07-20-2010 06:33 PM
I'll begin with this one that's more of a curiosity than a useful snippet.
I saw it here (with an explanation) and had to test it in LabVIEW. Someone is very clever.
What you can get out of this is an exercise in familiarity with the elements of Regular Expressions.
07-21-2010 05:35 AM
Why doesn't Johnny use Regular Expressions?
His mother doesn't let him play with matches. 😄
07-21-2010 10:13 AM
Took me a while to find the carrott.
I think you mean "caret" (pronounced same as carrott).....
Shane
07-21-2010 11:52 AM - edited 07-21-2010 11:53 AM
07-21-2010 01:07 PM - edited 07-21-2010 01:08 PM
Not to be confused with irregular expressions. 😄
07-21-2010 01:24 PM
@altenbach wrote:
Not to be confused with irregular expressions. 😄
You have to be an irregular guy to be able to understand irregular expressions.
07-23-2010 05:09 AM
This example demonstrates the oft-used expression: ".*" (dot star). You remember (right?) that a dot matches "any single character except line break characters \r and \n" and that the star "[r]epeats the previous item zero or more times." The parentheses save whatever is matched by the expression between them (you can use this later in your expression as a "backreference"). In this example I'm looking for the word "and", but I don't want to have to strip off the "start", "stop" or the whitespace later. I only use the Whole Match output to illustrate the function; the string I'm interested in is returned in the first submatch. (Note: MRE is an expandable node. You need to drag the bottom handle down to access the submatch terminals.)
This method should replace the following snippet:
Please don't ever do this again. 😛
07-23-2010 05:18 PM
Submatches are useful in extracting a part of your match but they also can also be reused in the regexp. An example is to match beginning and ending tags when you don't know what tag you're looking for.
The brackets are not special characters so they'll result in a literal match. The expression "(\w*)" creates a submatch that will contain zero or more word characters. The second element should look familiar to you but the last element is special. The "</" marks the beginning of a closing tag, but you can't just look for the first instance of this because there may be nested tags. Use the backslash to insert the first submatch (called a backreference) indicated by the number one. The desired text is in submatch 2, the second set of parentheses. You can test this by replacing "sarcasm" by another string.
07-26-2010 02:19 AM - edited 07-26-2010 02:21 AM
It might be an idea to add a 'RegEx' group on the communities?
In this group we could host a page with a table showing 'input text', 'Regex', 'match' and a description of the actual working of the regex.
That way it's better to manage and search than a thread with numerous responses.
Ton