現在、私は Android で作業しています。参考のために以下の結果のような文字列を 1 つ持っていますが、これを取得できませんでした。助けてください
String result ="error: not allowed | Native: XYZ ABC - Vodofone | Amount balance: 434"
「XYZ ABC - Vodofone」のようなネイティブ値を取得する方法
前もって感謝します。
クラスの使用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
配列に配置されます。
出来るよ:
result.substring(result.indexOf('|'), result.lastIndexOf('|'));
またresult.split("|");