Case insensitive String split() method

前端 未结 6 1598
北海茫月
北海茫月 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:38

    You can also use an embedded flag in your regex:

    String[] array = test.split("(?i)x"); // splits case insensitive
    

提交回复
热议问题