Menu

#18 Exception during ACCEPT_INCOMPLETE match

open
nobody
None
5
2006-04-24
2006-04-24
Anonymous
No

Hello!
I try to match strings while reading character by
character until it is wrong character in the input stream.
Strings I want to read are determined by the following
regular expressions:

(?<=^')[a-z]+(?='\Z)

It means, that I want all strings, that begins with "'"
and ends with "'" and between them there are chars from
a to z.

So I want, Matcher to accept, for example, following
input loop:

input begins
'
'h
'he
'hel
'hell
'hello
'hello'
'hello'f
DENY! String "'hello'f" does not matche();
input ends

When I try to perform
Matcher.findAll(Matcher.ACCEPT_INCOMPLETE)
it throws an Exception

Exception in thread "main"
java.lang.StringIndexOutOfBoundsException: String index
out of range: -1
at java.lang.String.substring(String.java:1768)
at jregex.Matcher.getString(jregex/Matcher.java:337)
at jregex.Matcher.toString(jregex/Matcher.java:630)
at .......

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.