Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 用正则表达式拆分字符串_Android_String - Fatal编程技术网

Android 用正则表达式拆分字符串

Android 用正则表达式拆分字符串,android,string,Android,String,我正在尝试用正则表达式拆分字符串。但它不起作用,内容将全部转移到字符串数组的第一个数组位置。这不对吗 scanResult不相关,只是一个简单的字符串 StringBuffer scanList = new StringBuffer(); for cycle{ scanList.append("SPl"+scanResult.SSID+"ID:"+scanResult.BSSID); } String result=scanList.toString(); String[] actual

我正在尝试用正则表达式拆分字符串。但它不起作用,内容将全部转移到字符串数组的第一个数组位置。这不对吗

scanResult不相关,只是一个简单的字符串

StringBuffer scanList = new StringBuffer();
for cycle{
    scanList.append("SPl"+scanResult.SSID+"ID:"+scanResult.BSSID);
}
String result=scanList.toString();
String[] actual=result.split("SP1");
“SPl”与“SP1”不同。第一个字符串中使用小写L,第二个字符串中使用数字1

我还将更新您的append String以附加所有值。通常,最好执行以下类似操作:

sb.append(val1).append(val2).append(val3).append(val4);

似乎在您的
追加中有
SPl
(S-p-小写字母l),在
拆分中有
SP1
(S-p-One)