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?
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?
Well, if you guarantee that each start tag is followed by an end tag then the following would work.
However, If you have complex text such as the follwoing:
then you would run into problems with regex.
Now the following example will pull out all the hot links in a page:
In the above case we can guarantee that there would not be any nested cases of:
So, this is a complex question and can't just be solved with a simple answer.
With Perl you can surround the data you want with ()'s and pull it out later, perhaps other languages have a similar feature.
Reading the text with in the square brackets [] i.e.[Start] and [End] and validate the array with a list of values. jsfiddle http://jsfiddle.net/muralinarisetty/r4s4wxj4/1/
Refer to this question to pull out text between tags with space characters and dots (
.
)[\S\s]
is the one I usedRegex to match any character including new lines
Zhich'll put the text in the middle within a capture.
I had a similar problem for a while & I can tell you this method works...