fork download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String FileContent = "2017-04-03, 11:25, 2; 2017-04-02, 11:30, 8; 2017-04-03, 14:42, 9";
  11. String date= "2017-04-03";
  12. List<String> MatchingContent = new ArrayList<>();
  13. Matcher m = Pattern.compile(date + "[^;]+").matcher(FileContent);
  14. while(m.find()) {
  15. MatchingContent.add(m.group());
  16. }
  17. System.out.println(MatchingContent);
  18. }
  19. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
[2017-04-03, 11:25, 2, 2017-04-03, 14:42, 9]