Regex & Multiline pattern between 2 tags (a better way).
843785Oct 2 2008 — edited Oct 20 2008Hi there,
I've a String which contains 2 known tags and a bunch of data on a multilines in-between (those data and number of lines are un-known (can be different everytime).
I'm using a regex to find the data and replace it. BUT would like to find a more elegant way of doing it.
Here is example of my String:
------------------------------------------
<actualCommand><?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header>
.....
xmlns:wsss+="</soapenv:Header><soapenv:Body>
<default:rpc xmlns=" message-id="742">
<default:edit-config> <target> </target> <config>
.....
.....
bla-bla-bla
.....
.....
</config></default:edit-config>
</default:rpc>
</soapenv:Envelope></actualCommand>
------------------------------------------
Here is my regex I'm using (and it works fine):
=====================
String regexActualCommand = "<actualCommand>[A-Za-z0-9 !@#$%^&\"?<>/:;\'=,.\n\r\t\\+-]*</actualCommand>";
=====================
Is there are more elegant for regex??? I tried this one - but it works if there is 1 line only in-between those tags: String regexActualCommand = "<actualCommand>.+</actualCommand>";