LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

match pattern to find matching brackets?

Can I use 'Match Pattern' to find pairs of matching brackets (they may
contain additional bracket pairs inside)?
How?
0 Kudos
Message 1 of 4
(3,397 Views)
In Regular Expression syntax, the bracket characters ("[", "]") have special meaning. Any special characters may be escaped with a slash ("\") and will not be interpreted according to their special meaning, but rather for the character itself. To do the operation you desire (finding "pairs" of matching brackets), you cannot simply use the Match pattern function. There is some logic that needs to occur. You are essentially digging into a compound data structure. You will need to keep track of how deep you are in the structure. For example, if you find a "[" before a "]" you are one level deeper in the structure. Anyhow, I have attached a VI that will help you get started. You will need to add some error handling and recovery. Also, make note of the
use of the while loop. Make sure you don't get stuck in an infinite loop.

Good luck,

-Jim
0 Kudos
Message 2 of 4
(3,397 Views)
Thanks!
I was afraid that regular expressions, as powerful as they are, are not THAT
powerful.
You've confirmed it

-Franz


"Jim Kring" schrieb im Newsbeitrag
news:506500000005000000D00E0100-1042324653000@exchange.ni.com...
> In Regular Expression syntax, the bracket characters ("[", "]") have
> special meaning. Any special characters may be escaped with a slash
> ("\") and will not be interpreted according to their special meaning,
> but rather for the character itself. To do the operation you desire
> (finding "pairs" of matching brackets), you cannot simply use the
> Match pattern function. There is some logic that needs to occur. You
> are essentially digging into a compound data structure. You will need
> to keep track of how deep y
ou are in the structure. For example, if
> you find a "[" before a "]" you are one level deeper in the structure.
> Anyhow, I have attached a VI that will help you get started. You will
> need to add some error handling and recovery. Also, make note of the
> use of the while loop. Make sure you don't get stuck in an infinite
> loop.
>
> Good luck,
>
> -Jim
0 Kudos
Message 3 of 4
(3,397 Views)
However, LabVIEW's Match Pattern function only uses a very small subset of the Regular Expression (RE) synatax. I would not be suprised if the full RE syntax is capable of performing the "bracket pairs" task that you are seeking.

-Jim
0 Kudos
Message 4 of 4
(3,397 Views)