I have a big text file. I'm interested only in the beginning tag and the text between a beginning and an end tag.
textfile.txt
Any text is in this document. But I'm only interested in the text between a beginning and an end tag +. BEGIN_TAG_110 In this text I'm interested in. It can consist of several lines. Until the end tag. END_TAG and any other things I'm not interested in until the next begi +nning tag starts. Any other text. BEGIN_TAG_237 I need this text. END_TAG More text ...
The result should be like this:
# BEGIN_TAG_110: # In this text I'm interested in. # It can consist of several lines. Until the end tag. # # BEGIN_TAG 237: # I need this text.
I'd like to have the beginning tag as the key of a hash and the corresponding text as its string value.
I tried this regular expression:
m/^.*BEGIN_TAG_(\d+)(.*)END_TAG.*/s;But it works only with the last one. It seems to be too greedy. But my main problem is how not to get only one, but all.
I'm really interested in how it could be done in a good manner or for any hints from you. Thank you!!
In reply to Get text between start and end tag by Dirk80
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |