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

Question

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?

Answer

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

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

< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/1237/" >Regex: To pull out a sub-string between two tags in a string< /a>
Share on Google Plus

About Cinema Guy

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment