Menu

#1 '-' is not allowed in a character class

open
nobody
None
5
2002-04-02
2002-04-02
No

jregex the following exception when it encounters a string like "[-0-
9A-z]" in a pattern:

jregex.PatternSyntaxException: [-...] is
illegal

How can I then specify a character class which includes
a '-' (minus) sign? I have been so far using a library which allowed the
first character in a class to be '-'.

Thanks,
Alexander
Maryanovsky.

Discussion

  • Sergey A. Samokhodkin

    Logged In: YES
    user_id=367459

    > How can I then specify a character class which includes
    > a '-' (minus) sign?

    The current syntax requires the '-' to be escaped to have a
    literal meaning within a char class , like [\-0-9a-z] (the
    corresponding java literal is "[\\-0-9a-z]").

    Consider submitting a feature request.

     
  • Alexander Maryanovsky

    Logged In: YES
    user_id=503759

    Actually, what I did in the meanwhile was commenting line 397 and
    uncommenting line 396. This seems to work perfectly... Are there any
    problems with that modification I should be aware of?

    Alexander
    Maryanovsky.

     

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.