regex pattern question

Hi,

I'm trying to get my feet wet wtih java and regular expressions, done a lof of it in perl, but need some help with java.

I have an xml file (also working through the sax tutorial, but this question is related to regex)that has multiple elements, each element has a title tag:

<element lev1>10<title>element title</title>

<element lev2>20<title>another element title</title>

</element lev2>

</element lev1>

If I have the following pattern:

Pattern Title = Pattern.compile("(?i)<title>([^<]*)</title>");

that picks up the titles, but I can't distinguish which title belongs to which element. Basically what I want to have is:

Pattern coreTitle = Pattern.compile("(?i)<element lev1>(**any thing that isn't an </title> tag**)</title>");

looked through the tutorials, will keep looking, I'm sure it's in there somewhere, but if someone could point me in the right direction, that would be great.

thanks,

bp

[1130 byte] By [badpersona] at [2007-11-27 5:49:57]
# 1
> l, but if someone could> point me in the right direction, that would be great.> Zero width negative look ahead.
sabre150a at 2007-7-12 15:37:10 > top of Java-index,Java Essentials,New To Java...
# 2
Just guessing, but maybe...Pattern.compile("(?i)<element lev1>*<title>([^<]*)</title>");But it seems that things like parsing with SAX (or loading to a DOM) or XPath would be much better suited to parsing out XML then regexp.
bsampieria at 2007-7-12 15:37:10 > top of Java-index,Java Essentials,New To Java...
# 3
this one should also work:Pattern coreTitle = Pattern.compile("(?i)<element lev1>.*?<title>(.*?)</title>");
S_i_m_ua at 2007-7-12 15:37:10 > top of Java-index,Java Essentials,New To Java...