I'm trying to write a small C program that takes a file containing this:

<mytag> "HELLO" </mytag> asdfasdfadsfadsf <mytag> "WORLD" </mytag>

... and fetches HELLO and HELLO using regular expressions.

I have everything set up in place, this is the regexp I'm using:

<mytag>.*(HELLO).*</mytag>

The problem is that this matches the ENTIRE string. So I got the tip to use lazy quantifiers, like so:

<mytag>.*?(HELLO).*?</mytag>

which *would* work if the regexp engine was regexp directed, not text directed. But sadly, it does not.

So my question, which I'd be very happy to have answered, is how do I write a regexp that matches, with HELLO as a substring, the above and just the first part of the string?

Does the question make sense?

TIA!