Solved

java.util.regex.PatternSyntaxException: Illegal character range error

Posted on 2008-10-29
2
2,937 Views
Last Modified: 2008-10-29
while debugging some code, I ran across this error:

Caused by: java.util.regex.PatternSyntaxException: Illegal character range near index 14
\bFOR [A-Z][1-0] ADD\b
^

I've never worked with regular expressions much in java, but I have in perl.  that error seems to me like it is being caused by the [1-0] range.  shouldn't the correct way to specify that would be [0-1]?  just wanted to make sure I'm on the right track.  thanks!
0
Comment
Question by:texasreddog
  • 2
2 Comments
 
LVL 8

Expert Comment

by:MatthiasVance
ID: 22834103
The correct way of specifying a character range is indeed [beginChar-endChar], as you stated.

Kind regards,

Matthias Vance
0
 
LVL 8

Accepted Solution

by:
MatthiasVance earned 500 total points
ID: 22834111
But on the other hand, you can just do [01] if you want to catch both 0 and 1.
There's no need to specify a range for that.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now