import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(\\d{2,4})-?(\\w{3}|\\d{2})-(\\d{2,4})";
final String string = "Dear Customer, SBI MUTUAL FUND ISIP bill of Rs. 5000 has been presented at !ClClBank.com. It would be debited through autodebit on due date 20-Nov-19\n"
+ "ALERT:You've spent Rs.1936.00 via Debit Card xx2127 at OM SAI MEDICINERS on 2020-01-03:13:02:10.AvI Bal Rs.66697.85.Not you?Call 18002586161\n"
+ "AvbI Bal in your A/C. No.XXXXXXXXXXX31 34 on EOD 30DEC-2019 is INR 34,072.58, Tot. avbl bal (including linked deposits and Limit) is INR 34,072.58\n"
+ "NEFT Transaction with reference number 21854417971DC for Rs. 8600.00 has been credited to the beneficiary account on 04-01-2020 at 09:35:46\n"
+ "Your A/c XXXXXXXXXXXX103 in Pune-Deccan Gymkhana credited INR 3326.00 on 03-01-2020 by TRF. AvI Bal is +20094.13\n"
+ "Ur transaction on HDFC Bank DEBIT/ATM Card ending 2127 for Rs. 860.00 has been credited/reversed by DUTTA BHANDAR on 2020-01-02:14:12:23\n"
+ "Dear Customer, SBI MUTUAL FUND ISIP bill of Rs. 5000 has been presented at !ClCiBank.com. It would be debited through autodebit on due date 20-Nov-19\n"
+ "Your A/c XXXXXXXXXXXX103 in Pune-Deccan Gymkhana debited INR 2000.00 on 24-12-2019 by TRF. AvI Bal is +5583.13\n"
+ "Acct XX852 debited with INR 4,499.00 on 02-Dec-19 & Acct XX248 credited. IMPS: 933612258069. Call 18002662 for dispute or SMS BLOCK 852 to 9215676766\n"
+ "ALERT:You've spent Rs.860.00 via Debit Card xx2127 at DUTTA BHANDAR on 2020-01-02:14:15:34.AvI Bal Rs.68633.85.Not you?Call 18002586161\n"
+ "Txn of INR 301.86 done on Acct XX278 on 27-Nov-19.Info: IIN*Zomato .Avbl Bal:INR 6,14,402.34.Call 18002662 for pute or SMS BLOCK 278 to\n"
+ " ‘Txn of INR 1,477.00 done on Acct XX340 on 03-Jan-20.Info: IPS*Oak groov.Avbl Bal:INR 24,296.14.Call 18002662 for dispute or SMS BLOCK 340 to 9215676766\n"
+ " Txn of INR 130.00 done on Acct XX278 on 25-Nov-19.Info: IIN*Zomato .Avbl Bal:INR 6,14,855.76.Call 18002662 for dispute or SMS BLOCK 278 to 9215676766\n"
+ "ALERT:You've spent Rs.1000.00 via Debit Card xx2127 at OM SAI MEDICINERS on 2020-01-03:13:02:40.AvI Bal Rs.65697.85.Not you?Call 18002586161\n"
+ "ALERT: You've spent Rs.110370.00 on CREDIT Card xx8248 at KEJALS FURNISHINGS on 2020-01-04:15:13:21. AvI bal - Rs. 213979.00, curr o/s Rs.150021.00.Not you? Call 18002586161\n"
+ "Acct XX340 debited with INR 4,622.83 on 01-Jan-20.Info: BIL*001884473.AvbI Bal:INR 25,773.14.Call 18002662 for dispute or SMS BLOCK 340 to 9215676766\n"
+ "Ur transaction on HDFC Bank CREDIT Card ending 8248 for Rs. 2.00 has been credited/reversed by AMAZON on 2020-01-06:05:25:42\n"
+ "Dear Customer, Payment of INR 4622.83 has been received on your ICICI Bank Credit Card Account 4xxx5004 on 01-JAN-20.Thank you\n"
+ "Your Ac XX2148 is debited with INR10,000.00 NFS*CASH WDL*30-12-15. Avbl Bal INR1,87,552.27 To bank on phone with iMobile, click mobile.icicibank.com/dl\n"
+ "Txn of INR 141.00 done on Acct XX340 on 31-Dec-19. Info: IIN*Amazon_ .AvbI Bal:INR 30,255.97.Call 18002662 for dispute or SMS BLOCK 340 to 9215676766\n"
+ "INR219.00 debited on Credit Card XX4005 on 26Nov-19.Info:APPLE.COM BILL.AvbI Lmt:INR8,643.51.Call 18002662 for dispute or SMS. BLOCK 4005 to 9215676766\n"
+ "Your a/c no. XXXXXXXX4876 is debited for Rs. 2000.00 on 02-01-20 and a/c XXXXXXX017 credited (IMPS Ref no 000216702189). Download YONO @ www.yonosbi.com\n"
+ "ALERT: You've spent Rs.1000.00 on CREDIT Card xx8248 at AMAZON on 2020-01-05:22:54:14 -AvI bal - Rs. 208004.00, curr o/s Rs.155996.00.Not you? Call 18002586161\n"
+ "Dear Customer, payment of Rs. 5000 towards SBI MUTUAL FUND ISIP is scheduled on 20-Nov-19. Pls maintain sufficient balance in Acct XX2148\n"
+ "ALERT: You've spent Rs.3100.00 on CREDIT Card xx8248 at D.J.PETROLEUM on 2019-11-29:12:35:16. AvI bal - Rs. 271584.00, curr o/s Rs.8416.00.Not you? Call 18002586161\n"
+ "Dear Customer, bill of Rs. 738 towards BSNL CELL ONE PUNE is due on 21-Nov-19. To make a payment, click https://icici.in/ PR5PO7k or login to Internet Banking/ iMobile\n"
+ "Dear Customer, Your a/c no. XXXXXXXX4435 is credited by Rs. 74,739.00 on 09Aug-2018 00:45:17 by a/c linked to mobile XXXXXO0O0000. (IMPS Ref no 822100339658).\n\n";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html