LabVIEW Idea Exchange

About LabVIEW Idea Exchange

Have a LabVIEW Idea?

  1. Browse by label or search in the LabVIEW Idea Exchange to see if your idea has previously been submitted. If your idea exists be sure to vote for the idea by giving it kudos to indicate your approval!
  2. If your idea has not been submitted click Post New Idea to submit a product idea to the LabVIEW Idea Exchange. Be sure to submit a separate post for each idea.
  3. Watch as the community gives your idea kudos and adds their input.
  4. As NI R&D considers the idea, they will change the idea status.
  5. Give kudos to other ideas that you would like to see in a future version of LabVIEW!
Top Authors
cancel
Showing results for 
Search instead for 
Did you mean: 
SteenSchmidt

Regular expression should support grouping by parentheses as well as the empty string constant

Status: Completed
This idea is already in LV

Regular expressions in LabVIEW supports parentheses for partial matches, but this fails if your partial match is a set of operators.

 

Let's say I want to match "XYZ_Level" or "Level", where XYZ can be any number of characters including an empty string, the underscore must be there if XYZ is different from an empty string. These strings are valid candidates for instance:

 

"Level"

"_Level"

"a_Level"

"much:more_Level"

 

These aren't:

 

"aLevel"

"abc_defLevel"

 

I'd construct a regular expression as input to the Match Pattern primitive like this then: "(.*_)?Level", but this fails matching any of the good examples above. I think the parentheses fail to parse correctly when they contain operators? I have also tried specifying a partial match using the pipe character, like this: "(.*_|)Level", but this won't work either, probably because I need something on the right hand side of the pipe to tell the regex parser that the alternative is an empty string. An empty string is usually denoted by the epsilon character in regular expressions, but LabVIEW doesn't recognize that.

 

So, (unless I'm mistaken) I'd suggest LabVIEW to support parenthese in regular expressions as means of grouping anything including operators, not only substrings.

 

Cheers,

Steen

CLA, CTA, CLED & LabVIEW Champion
3 Comments
dthor
Active Participant

Have you tried the Match Regular Express primitive?

 

The Match Pattern primitive is a dumbed-down version of POSIX RegEx: it allows only the most common expressions so that speed and eficiency are increased.

SteenSchmidt
Active Participant

Oh boy, I never knew the difference between these two primitives in regard of regular expression support. And it is even written in detailed help.

 

Match Regular Expression works with my expression. Thanks!

 

Cheers,

Steen

CLA, CTA, CLED & LabVIEW Champion
JordanG
NI Employee (retired)
Status changed to: Completed
This idea is already in LV