我如何从句子中获取字符串值?

时间:2016-10-07 06:17:00

标签: java android

我想获取IMPS Ref no。来自字符串 我怎样才能做到这一点?我的提取方法是

// I want to fetch it with IMPS Ref. No.
String Result="Your A/c No. XXXXXXXX2335 is debited for Rs. 20 on 04-10-16 and A/c linked to mobile 9818685050 credited " +
                    "( IMPS Ref No. 627814178257 )";

if(Result.indexOf("IMPS Ref No.") > 0)
{
    System.out.println(Result.indexOf("IMPS Ref No."));
    String[] result=Result.split("\\(");
    System.out.println(result[1]);
    String imps=result[1];
    String numberOnly= imps.replaceAll("[^0-9]", "");
    System.out.println(numberOnly);
 }

0 个答案:

没有答案