-6

現在、私は Android で作業しています。参考のために以下の結果のような文字列を 1 つ持っていますが、これを取得できませんでした。助けてください

String result ="error: not allowed | Native: XYZ ABC - Vodofone | Amount balance: 434"

「XYZ ABC - Vodofone」のようなネイティブ値を取得する方法

前もって感謝します。

4

2 に答える 2

3

クラスの使用split方法:String

String result ="error: not allowed | Native: XYZ ABC - Vodofone | Amount balance: 434"
String[] results = result.split("|");
// results[0] = "error: not allowed "
// results[1] = "Native: XYZ ABC - Vodofone "
// results[2] = "Amount balance: 434 "

コメントに示されている結果のエントリは、String配列に配置されます。

于 2012-08-16T14:24:09.750 に答える
0

出来るよ:

result.substring(result.indexOf('|'), result.lastIndexOf('|'));

またresult.split("|");

于 2012-08-16T14:28:02.917 に答える