title: Extract (parse) amount and description from BIZ (Transaction) sms
body: <p>I am doing below steps.</p>
  
  <ol>
  <li><p>match sms with regex</p></li>
  <li><p>if contains specified keyword then get values from sms body like <strong>amount,description (reason of transaction), Account number(if ATM withdraw),transaction type(debit/credit)</strong></p>
  
  <p>this regex not matching all kind of bank/transaction sms thus it is not efficient , is there any other way to identify bank message.</p></li>
  </ol>
  
  <p>example sms :</p>
  
  <p>1) Dear Customer, your Account Number <strong>XXXXXX6377</strong> has been <strong>credited</strong> by <strong>Rs            215.000</strong> being DBT/DBTL funds transfer on 19/05/2015 - CENTRAL BANK OF INDIA </p>
  
  <p>2)A/c NN5715 <strong>debited</strong> for <strong>Rs 2000</strong>; ATM WDL. A/c Bal(sub to chq realisatn) Rs13286.23 on 24APR 21:19hr. Call 1800226999 to block your card if not used by you.</p>
  
  <p>3) Dear Customer, Your Ac <strong>XXXXXXXX5666</strong> is <strong>credited</strong> with <strong>INR8,922.00</strong> on 16 Feb. Info. INF*000080483346*SALARY. Your Net Available Bal is INR 8,922.00.</p>
  
  <pre><code>private static ArrayList&lt;SmsDto&gt; parsevalues(ArrayList&lt;SmsDto&gt; body_val) {
      ArrayList&lt;SmsDto&gt; resSms = new ArrayList&lt;&gt;();
      for (int i = 0; i &lt; body_val.size(); i++) {
          SmsDto smsDto = body_val.get(i);
          Pattern regEx
                  = Pattern.compile("(?:inr|rs)+[\\s]*[0-9+[\\,]*+[0-9]*]+[\\.]*[0-9]+");
          // Find instance of pattern matches
          Matcher m = regEx.matcher(smsDto.getBody());
          if (m.find()) {
              try {
                  Log.e("amount_value= ", "" + m.group(0));
                  String amount = (m.group(0).replaceAll("inr", ""));
                  amount = amount.replaceAll("rs", "");
                  amount = amount.replaceAll("inr", "");
                  amount = amount.replaceAll(" ", "");
                  amount = amount.replaceAll(",", "");
                  smsDto.setAmount(Double.valueOf(amount));
                  if (smsDto.getBody().contains("debited") ||
                          smsDto.getBody().contains("purchasing") || smsDto.getBody().contains("purchase") || smsDto.getBody().contains("dr")) {
                      smsDto.setTransactionType("0");
                  } else if (smsDto.getBody().contains("credited") || smsDto.getBody().contains("cr")) {
                      smsDto.setTransactionType("1");
                  }
                  smsDto.setParsed("1");
                  Log.e("matchedValue= ", "" + amount);
                  if (!Character.isDigit(smsDto.getSenderid().charAt(0)))
                      resSms.add(smsDto);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          } else {
              Log.e("No_matchedValue ", "No_matchedValue ");
          }
      }
      return resSms;
  }
  </code></pre>