multiline regex expression

E

eggie5

This should have been an easy expression to build, but I can't figure
it out.



I just want to match any text between the <!--scripts--> and <!-
endscripts--> tag:



<!--scripts-->
<script src="assets/scripts/tabber.js" type="text/javascript"></
script>

<script type="text/javascript" src="management.js"></script>

<script type="text/javascript" src="assets/scripts/prototype.js"></
script>

<script src="assets/scripts/scriptaculous.js" type="text/
javascript"></script>

<script type="text/javascript" src="assets/scripts/
MMSService.js"></script>

<!--endscripts-->
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

eggie5 said:
This should have been an easy expression to build, but I can't figure
it out.



I just want to match any text between the <!--scripts--> and <!-
endscripts--> tag:



<!--scripts-->
<script src="assets/scripts/tabber.js" type="text/javascript"></
script>

<script type="text/javascript" src="management.js"></script>

<script type="text/javascript" src="assets/scripts/prototype.js"></
script>

<script src="assets/scripts/scriptaculous.js" type="text/
javascript"></script>

<script type="text/javascript" src="assets/scripts/
MMSService.js"></script>

<!--endscripts-->

<!--scripts-->([\w\W]*?)<!--endscripts-->
 
J

Jesse Houwing

* eggie5 wrote, On 21-7-2007 6:31:
This should have been an easy expression to build, but I can't figure
it out.



I just want to match any text between the <!--scripts--> and <!-
endscripts--> tag:



<!--scripts-->
<script src="assets/scripts/tabber.js" type="text/javascript"></
script>

<script type="text/javascript" src="management.js"></script>

<script type="text/javascript" src="assets/scripts/prototype.js"></
script>

<script src="assets/scripts/scriptaculous.js" type="text/
javascript"></script>

<script type="text/javascript" src="assets/scripts/
MMSService.js"></script>

<!--endscripts-->

Or little easier:
<!--scripts-->.*?<!--endscripts-->

Be sure to set the option SingleLine for the regex. This migth sound
strange, but I'll try to explain. SingleLine does not mean to treat each
line, but to treat the whole input as one line. Normally the . won't
skip over a line end, but with this option on it will.

Jesse
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top