Doubt in Regular Expressions
I started learning Regular Expressions. I am stuck in following.
http://java.sun.com/docs/books/tutorial/extra/regex/literals.html
In the above url, i didnt understand following:
"Note that while the input string is 3 characters long, the start index is 0 and the end index is 3. By convention, ranges are inclusive of the beginning index and exclusive of the end index"
I didnt understand why the end index is 3 instead of 2.
[457 byte] By [
@a] at [2007-10-2 9:04:35]

> exclusive of the end index means that the end
> index is the last index of the match + 1 (one
> character after the last index).
> Since the last index of the match is 2, then the end
> index will be 3.
I am finding it hard to understand. Could you please explain in bit more detail. As i am in starting stage, i want to understand it clearly.
@a at 2007-7-16 23:11:36 >

When you have the range 0-3, the beginning index is zero and the end index is 3.
Inclusive of the start index means the result includes the character at index 0.
Exclusive of the end index menas it excludes (does NOT include) the character at index 3.
So in the range 0-3--that is, 0, 1, 2, 3--we include the 0, but we don't include the 3. So we get characters 0, 1, and 2.
jverda at 2007-7-16 23:11:36 >

Note that this makes sense because then the range 0..3 has 3-0=3 characters. Likewise, any range M..N will have M-N chars.For instance, 4..9 will have 9-4=5 chars--4, 5, 6, 7, 8.
jverda at 2007-7-16 23:11:36 >
