The range in the search string must have valid minimum value and maximum value in the regular expression. If the invalid starting character or ending character is provided in the range, the regular expression can not identify the range of the characters in the search string. The starting character and ending character should be specified with ‘-‘ hyphen symbol. The regular expression supports to specify the range of characters in the search string.
} Output Exception in thread "main" 圎xception: Illegal character range near index 3 Hence, the exception 圎xception: Illegal character range near index will be thrown. If an invalid range is defined in a regular expression, either an invalid character is entered or a special character is used without an escape character, the range of values can not be determined. Exception in thread "main" 圎xception: Illegal character range near index 3Īt .error(Pattern.java:1955)Īt .range(Pattern.java:2655)Īt .clazz(Pattern.java:2562)Īt .sequence(Pattern.java:2063)Īt .expr(Pattern.java:1996)Īt .compile(Pattern.java:1696)Īt .(Pattern.java:1351)Īt .compile(Pattern.java:1028)Īt (String.java:2223)Īt (StringReplaceAll.java:9) The java exception 圎xception: Illegal character range near index will be thrown as a stack trace below. If an invalid range is defined or an invalid character is entered or some special character is used without an escape character, the exception 圎xception: Illegal character range near index will be thrown. The ‘-‘ hyphen is used between the minimum and the maximum values. The range will be defined using the minimum and maximum values. When an invalid range is specified or an invalid character is entered, the regular expression can not define the range of characters. The value of the character range is 65 to 67. For example, the value of ‘A’ is 65 and the value of ‘C’ is 67. In regular expression, the character range will be defined using a hyphen character in between minimum and maximum characters. If an invalid minimum or maximum value is specified in the regular expression, the exception 圎xception: Illegal character range near index is thrown. The range is defined by a hyphen in between minimum and maximum values.
The java exception 圎xception: Illegal character range near index occurs when an Illegal or inappropriate character range is used to match the regular expression.