Case insensitive String split() method

前端 未结 6 1613
北海茫月
北海茫月 2020-12-10 01:48

When I perform

String test=\"23x34 \";
String[] array=test.split(\"x\"); //splitting using simple letter

I got two items in array as 23 and

6条回答
  •  一个人的身影
    2020-12-10 02:44

    Use regex pattern [xX] in split

    String x = "24X45";
    String[] res = x.split("[xX]");
    System.out.println(Arrays.toString(res));
    

提交回复
热议问题