fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String regex = "(?i)\\b(?:balance|credit\\s+limit)\\s+[A-Za-z]+(?:\\s+[A-Za-z]+)*\\s+Rs\\.\\s*(\\d+(?:[.,]\\d+)*)";
  12. String string = "account ending with ********9415 has been credited with Rs. 5000. Updated account balance is Rs. 13086.18\n\n"
  13. + "Your card transaction of Rs.417 is successful. Your updated credit balance is Rs.78,468\n\n"
  14. + "Dear Cardmember, payment of Rs.7657.00 has been received towards your Bank Credit Card ending with 3459 on 12-11-2020 through NEFT. Payment is subject to realisation. Your available Credit limit now is Rs. 173281.31.";
  15.  
  16. Pattern pattern = Pattern.compile(regex);
  17. Matcher matcher = pattern.matcher(string);
  18.  
  19. while (matcher.find()) {
  20. System.out.println(matcher.group(1));
  21. }
  22. }
  23. }
Success #stdin #stdout 0.1s 48432KB
stdin
Standard input is empty
stdout
13086.18
78,468
173281.31