Q:

Regex: To pull out a sub-string between two tags in a string

I have a file in the following format:

Data Data
Data
[Start]
Data I want
[End]
Data

I'd like to grab the Data I want from between the [Start] and [End] tags using a Regex. Can anyone show me how this might be done?

A:

\[start\](.*?)\[end\]

Zhich'll put the text in the middle within a capture.

A:

\[start\]\s*(((?!\[start\]|\[end\]).)+)\s*\[end\]

This should hopefully drop the [start] and [end] markers as well.

A:

$text ="Data Data Data start Data i want end Data";
($content) = $text =~ m/ start (.*) end /;
print $content;

I had a similar problem for a while & I can tell you this method works...

