The regular expression matches one of the characters listed inside square brackets. ("Output String : " + str2) Ĭreate the regular expression with close square bracket. The following example throws the exception. If not, you try to match open square bracket “[” without using proper escape character.Ĭonstruct a regular expression with a open square bracket and without close square bracket or without any escape characters. In the regular expression, the open square bracket “”. The “” square bracket is used to group characters to match one of the characters in a given String. The stack trace of the exception 圎xception: Unclosed character class near index 0 will be shown as below Exception in thread "main" 圎xception: Unclosed character class near index 0Īt .error(Pattern.java:1955)Īt .clazz(Pattern.java:2548)Ī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 exception “圎xception: Unclosed character class near index” will be thrown if the open square bracket is available without a close square bracket. If any character in the square bracket matches the given string, it will be true. The regular expression uses the “” square bracket to match one of the characters with a character in a string. In a search string, the special character (open square bracket) must escape. The java exception 圎xception: Unclosed character class near index 0 happens when the string is matched by the regular expression special character ‘[’ open square bracket.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |