/ Published in: Regular Expression
If there will be multiple sets of these tags in a scanned XML string, you need the '?' after the '*' to specify a non-greedy (lazy) match.
Expand |
Embed | Plain Text
(?<=Message\>)[\S\s]*?(?=\<\/Message)
Comments
Subscribe to comments
You need to login to post a comment.

Note that this only works with RegEx engines that support lookaround and non-greedy matching, which is not guaranteed.
If you do not have those options, you can capture the contents in parentheses:
<Message>([^<]*)</Message>In loops, this is faster than using lookaround and non-greedy matching, too.
Good advice, thanks!