Regular Expression beginner search text files for a string

I'm a regular expression beginner.
I've got around 250 text files I want to examine.
I want to extract the text between two labels.
The labels will exist in each text file.
The text between the two labels may be a few characters or it may be a few lines of text.
1. What is the simplest application to run the regular expression from (initially thought of excel, vba?)
2. What would the actual regular expression be?

Note that you'll need the option active for the . character to match newlines, otherwise you won't pick up the cases where the text spans multiple lines. Usually there's a checkbox for setting that option near to where you enter the regular expression. In Perl compatible regex's the option is "s".

I'd use Python because it's easy to learn and handles standard Perl-compatible regular expressions; in that case the attached program will work. Note the angle-brackets are part of my example labels, no special meaning.
But I don't know for comparison what VBA has for regular expressions.

Pacane: grep won't handle multiple lines, and there's no such thing as a Linux shell.

Got your script to work, thanks
All that's left is
~ to search through all files *.txt (ok to have subdirectories?)
~ can I put the individual filename that the text is coming from at the beginning of each line of the outputted text?

A Windows based product I have used for many years which strongly supports regular expressions is FileLocator Pro. You can find it at http://www.mythicsoft.com. It supports regular expressions in the data content search, filename specification, and path names. It lets you start with beginner mode and switch to advanced mode in the interface, and includes an expression builder. I have been using it for about 5 years and it keeps getting better.
There is a free lite version of the product called Agent Ransack, which you can also download there.

Here is the Excel version. The code goes into a normal code module. The data is put into into the currently active worksheet. It handles multi line tags ok. The process strips away everything but the tag contents including non-printing characters (eg. end of line breaks). Please note the requirement to add a reference to "Microsoft Script Regular Expressions" in the Visual Basic Editor found in the menu Tools\References.

If you have problems it will be helpful if you upload one of your text files because there are so many variations possible.

Featured Post

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Whatever be the reason, if you are working on web development side, you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…

As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…

Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…