fork(4) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. import java.lang.*;
  4. import java.io.*;
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. String[] arrayOfLine = {"I.2 Other Interpretive Provisions" , "I.3 Accounting Terms","Including all","II.1 The Loans","II.3 Prepayments.","III.2 Illegality","IV.2 Conditions","V.2 Authorization","expected to have"};
  10. Pattern pat = Pattern.compile("^[A-Z]+\\.[0-9]+\\b");
  11. List<String> listOfHeadings = new ArrayList<>();
  12. for (String s : arrayOfLine) {
  13. Matcher m = pat.matcher(s);
  14. if (m.find()) {
  15. listOfHeadings.add(s);
  16. }
  17. }
  18. System.out.println(listOfHeadings);
  19.  
  20. }
  21. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
[I.2 Other Interpretive Provisions, I.3 Accounting Terms, II.1 The Loans, II.3 Prepayments., III.2 Illegality, IV.2 Conditions, V.2 Authorization]