RegEx - Indexed\Arrayed Named Capture groups?

Posted by Josh on Stack Overflow See other posts from Stack Overflow or by Josh
Published on 2010-06-14T18:41:59Z Indexed on 2010/06/14 19:22 UTC
Read the original article Hit count: 351

Filed under:
|
|

I have a situation where something can appear in a format as follows:

---id-H--
Header: data
Another Header: more data
Message: sdasdasdasd
Message: asdasdasdasd
Message: asdasdasd

There may be many messages, or just a couple. I'd prefer not having to step outside of RegEx, because I am using the RegEx to parse some header information above the messages and the messages along with the headers are part of the text I am parsing. The messages attached into the text might be many.

I would also like to use named capture groups, so something like

Message: (?<Message[index of match]>.+)

Where it matches the match as many times as it can with the index filled in. Does anything like this exist in RegEx? (I will eventually be using this in Perl)

© Stack Overflow or respective owner

Related posts about regex

Related posts about perl