LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

match several submatches in multiple regular expression

Hi , I am using a Match Regular Expression to try to capture several lines into a set of sumatches

I have for example "String to match 1: OK" where I match the string and and test the OK with this (OK). It will look like this

String to match 1: (OK)

Now I want to add more strings to match

String to match 2: (OK)

String to match 3: (OK) and so on.

 

How can I write an expression for this?

String to match 1: (OK)String to match 2: (OK)  will not give any match at all

There can be several lines of text between the matching lines.

 

0 Kudos
Message 1 of 5
(5,177 Views)

This works for what I think you want: String to match 1: \(([^)]*)\)[\w\s]*to match 2: \(([^)]*)\), but I doubt that I understand what you want...  Give us an example of the input text and the desired outputs, like this:

 

Example_VI.png

 

You won't be able to have an arbitrary number of submatches defined at run-time.  My first thought was that you'd be better off looping through the text like this:

 

Example_VI.png

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 2 of 5
(5,149 Views)

Hi Jim,

no I don't want to have an arbitrary number of strings, just maybe 5-8 different (predefined though).

The input text can look like this, where I made the 2 first strings in red.

 


MemCfg: DCMM (Dynamically Configurable Memory Map) Version :  2.1.1.1
FIRMWARE: Memory Configuration status : In Progress
FIRMWARE: 1 start Successful
Loading HDVPSS Firmware
FIRMWARE: Memory map bin file not passed
Usage : firmware_loader <Processor Id> <Location of Firmware> <start|stop> [Location of Mem map bin file]
FIRMWARE: Default memory configuration is used
MemCfg: DCMM (Dynamically Configurable Memory Map) Version :  2.1.1.1
FIRMWARE: Memory Configuration status : In Progress
FIRMWARE: 2 start Successful
open /dev/fb0: No such file or directory

I tried to use your formating but with no success

FIRMWARE:\s1\sstart\s(Successful)[w\s]*FIRMWARE:\s2\sstart\s(Successful)

The submatches I am looking for here are "Successful" and "Successful"

0 Kudos
Message 3 of 5
(5,136 Views)

I prefer looping and finding all matches like I did in the top part of this example.

 

I don't know how to get it to match "FIRMWARE: 2" in the bottom part.  The "FIRMWARE: Memory..." is being matched before "2 start...".  I think that's what's ruining your regex, too.  Maybe someone else can chime in?

 

Example_VI.png

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 4 of 5
(5,105 Views)

Jim,

I gave up with the large regular expression (code on your lower part). When I tested the code in the upper part (the loop) I got as a result a "1" for index 0 and Successful for index 1 ?

 

I will probably go with something like this :

matchstring.png

This will work - I might need to do a match on the substring Successful to see that it is there

Thanks

 

0 Kudos
Message 5 of 5
(5,058 Views)