11-18-2013 10:23 AM
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.
11-18-2013 12:10 PM
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:
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:
11-18-2013 01:42 PM
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"
11-19-2013 06:12 AM
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?
11-20-2013 09:59 AM
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 :
This will work - I might need to do a match on the substring Successful to see that it is there
Thanks