LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
DavidBoyd

Allow Match Regular Expression to return submatches as an array of string, as an alternative to the growable node behavior

Status: New

I've encountered a programming situation where I may need to call 'Match Regular Expression' where the regex is selected at runtime, and where that regex may potentially have a variable number of submatches to return.  Unfortunately, right now, the submatch count is a compile-time decision based on how far out I grow the node.  I can grow the node to some maximum number of submatches ever expected, and thankfully the node doesn't throw a runtime error if there are fewer, or greater, submatch expressions in the regex.  I'm building the individual returns into a string array for further processing, but it would be much more versatile if the node could return the submatches with a properly-sized string array.

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
11 Comments
wiebe@CARYA
Knight of NI

Getting an array from an array of numbers is feasible. The VI I posted almost does that. It returns all groups as an array, but that is very simple to adapt to returning an indexed array. That would be pretty efficient as well. It would actually spend less time by adding this feature, which is always nice.

 

Getting a single capturing group is just as easy (or even easier). 

 

Getting both (an array an an element) would require either two or three VIs, or an XNode.

 

I know DIY isn't the same as including it in LabVIEW, but let me know if it will help. I can probably spend some time on it.

 

I don't think there's a way to link the resulting groups to the names of their group.