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
Well, if you guarantee that each start tag is followed by an end tag then the following would work.
\[start\](.*?)\[end\]
However, If you have complex text such as the follwoing:
[start] sometext [start] sometext2 [end] sometext [end]
then you would run into problems with regex.
Now the following example will pull out all the hot links in a page:
'/<a(.*?)a>/i'
In the above case we can guarantee that there would not be any nested cases of:
'<a></a>'
So, this is a complex question and can't just be solved with a simple answer.
Refer to this question to pull out text between tags with space characters and dots (.
)
[\S\s]
is the one I used
Regex to match any character including new lines
\[start\]\s*(((?!\[start\]|\[end\]).)+)\s*\[end\]
This should hopefully drop the [start]
and [end]
markers as well.