Java “如何提取”的一部分;“字符串”;安卓
我一直在试图提取“近甘戈特里医院”和“第125/6号8英里公共汽车站”,但我无法提取它。有人能帮我提取字符串吗 我需要提取第二个管道(|)操作符后面的第三个字符串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
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(“\\\\”);