PDA

View Full Version : VBA regex multiline match not working



byrnejeff
11-04-2007, 08:31 AM
Hello

I have something like this:

vv_TestMode : BOOL (Description := "Virtual Validation$NTest Mode Bit",
RADIX := Decimal) := 0;
InfotoCPL1_007Msg : MESSAGE (MessageType := CIP Data Table Write,
RemoteElement := "CPL1_001_Status",
RequestedLength := 1,
ConnectedFlag := 1,
ConnectionPath := "Enet02, 2, xxx.xx.xx.xx, 1, 0",
CommTypeCode := 0,
LocalIndex := 0,
LocalElement := "InfotoCPL1_007",
CacheConnections := "TRUE");
New_MSG : MESSAGE (MessageType := Unconfigured,

I want to get the word InfotoCPL1_007Msg, which is no problem, however I am having trouble getting what's between the 2 ( ), which spans multiple line. I can easily get the "MessageType := CIP Data Table Write" from the first line, but when I try to expand the match to get everything between ( ), it doesn't match.

Any suggestions?

Norie
11-04-2007, 09:13 AM
And where exactly do you have this and why are you using regular expressions?

Couldn't you use standard text functions?

byrnejeff
11-05-2007, 10:12 AM
No, it's a huge text file and to read it line by line is too slow.

Norie
11-05-2007, 12:36 PM
And did I suggest you do that?

byrnejeff
11-05-2007, 01:12 PM
Norie, I am specifically asking about regex, and I only want regex replys. Thanks for your interest anyway.

byrnejeff
11-05-2007, 01:13 PM
Oh, and just to be clearer, I want to capture what's between MESSAGE (....) for the second submatch.

Norie
11-05-2007, 01:14 PM
Well if that's the case why not post your current regular expression and the code you are using it in?:)

byrnejeff
11-05-2007, 01:24 PM
OK, as an example, this "^.*?(\w+) : MESSAGE \((.*?)," can capture up to ".....Table Write" no problem. But when you try to expand the second submatch to "...);", it doesn't work. It seems like when you try to expand it to another line, it doesn't work. I do have .MultiLine = True.