不区分大小写的 String split() 方法 [英] Case insensitive String split() method

查看:31
本文介绍了不区分大小写的 String split() 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我表演时

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

我在数组中有两个项目,分别是 23 和 34

I got two items in array as 23 and 34

但是当我这样做时

String test="23x34 ";
String[] array=test.split("X"); //splitting using capitalletter

我在 23x34 数组中得到了一项

I got one item in array 23x34

那么有什么办法可以将 split 方法用作不区分大小写的方法,或者是否有任何其他方法可以提供帮助?

So is there any way I can use the split method as case insensitive or whether there is any other method that can help?

推荐答案

split

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

这篇关于不区分大小写的 String split() 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆