Solved

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

Posted on 2008-10-29
2
3,046 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

829 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