Astha Sharma wrote:thanks to all for replying. I understand that pattern will search for a zero length string also. But i'm not getting that why it is continuing search beyond the matcher string. Matcher string doesn't have index upto 4.
Regular expressions searches for things other than text strings -- including
word boundaries, end of input boundaries, etc. As such, the position at the end of text is a valid position.
Now, a position such as 5 (greater than the length) is beyond the string.
Henry