But to answer why it always matches.... the first ".*" will basically greedily take the whole string, leaving the negative look ahead to always not match (meaning succeed), and the last ".*" to always have a zero length match.
First of all, it is a negative look ahead. It is not a negative match..... ie. "(?!2008)" is not the opposite case of "(2008)".
Originally posted by Henry Wong:
First of all, why "/"? Your example uses "#".
Second, take a look at the code again -- mine doesn't need to replace anything. It uses groups to extract the content in-between. (notice the group(1) call)
Thanks Henry. First of all, it should be # as I stated in my first post. what happened was after weekend, we started to deal with with "/" in a similar case. when I posted my code Tuesday, I changed the regex portion to comply with my original post but I forgot to change the "/" sign in the while loop.
Second, yes, you are right. the group(1) did it. This is my first time using the regex/pattern/match. my original understand on group() method was off. I did a further reading today and understand how to use number for group. Learned a lot. Thank you.
Henry
[ March 26, 2008: Message edited by: Henry Wong ]
Originally posted by Campbell Ritchie:
[Pedantic mode]There is no such thing as a multi-dimensional array in Java. What I suggested was an array of arrays.[/Pedantic mode]