Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.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
Java “如何提取”的一部分;“字符串”;安卓_Java_Android_Lexical Analysis - Fatal编程技术网

Java “如何提取”的一部分;“字符串”;安卓

Java “如何提取”的一部分;“字符串”;安卓,java,android,lexical-analysis,Java,Android,Lexical Analysis,我一直在试图提取“近甘戈特里医院”和“第125/6号8英里公共汽车站”,但我无法提取它。有人能帮我提取字符串吗 我需要提取第二个管道(|)操作符后面的第三个字符串 9649|14:30|Near Gangotri hospital |Opp Central Bank (Test)|9880955077|B T M Layout ~ 8937|14:34|no 125/6 8th Miles Bus Stop|Near 8th Mile Signal|080 65468012222|8th Mil

我一直在试图提取“近甘戈特里医院”和“第125/6号8英里公共汽车站”,但我无法提取它。有人能帮我提取字符串吗

我需要提取第二个管道(|)操作符后面的第三个字符串

9649|14:30|Near Gangotri hospital |Opp Central Bank (Test)|9880955077|B T M Layout ~ 8937|14:34|no 125/6 8th Miles Bus Stop|Near 8th Mile Signal|080 65468012222|8th Mile
您可以使用拆分文本,然后选择所需的部分

String text = "9649|14:30|Near Gangotri hospital |Opp Central Bank (Test)|9880955077|B T M Layout ~ 8937|14:34|no 125/6 8th Miles Bus Stop|Near 8th Mile Signal|080 65468012222|8th Mile";
String parts[] = text.split("|");
String part3 = parts[2]; //Near Gangotri hospital 

您尝试过子字符串方法吗?like string.substring(11,32);看看能不能找到附近的甘戈特里医院。可能需要调整位置。我很确定你不能做
text.split(“|”)因为管道是正则表达式中的特殊字符。我认为您需要执行
text.split(Pattern.quote(“|”)字符串部分[]=text.split(“\\\\”);