I've been trying to create a regexp to find text between, but not including, two strings. Finding the text between PLUSS the two strings was easy. But finding a way to not get the the two strings also wasn't as easy...

What i'm doing now is just getting the entire text and doing a replace afterwards, but this seems a bit silly really.

What i want to is to find whatever text (text, numbers, everything really) that is between 'display>' and '</a>' and somehow exclude 'display>' and '</a>' from the result.

An example:
<table class=..... display>the text i want</a> ......</table>

What i'm doing now:
VB Code:
  1. String content = "<table class=....display>the text i want</a>....</table>";
  2. StringBuffer text = new StringBuffer();
  3. pattern = Pattern.compile("display>.*?<");
  4. m = pattern.matcher(content);
  5. while (m.find()) {
  6.   textappend( m.group().replace("display>", "").replace("<", "").trim() + "\r\n" );
  7. }

This will return the text AND the two strings, like this:
display>the text i want</a>

and not like I would really want it, like this:
the text i want

And then I have to, as I said, do a replace on the string afterwards to remove the 'display>' and '</a>' parts.

SO! The question is, how can I exclude them from the result using regexp?