Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. import java.util.*;
  2. import java.util.regex.Pattern;
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) {
  7. /**
  8. * CrewManifestUpdate\_\[2\d{3}[0-1]\d[0-3]\d(['’])T\1[0-2]\d{5}[Z]\]\.(csv|CSV)
  9. [11:17:03] Piotr Rybarczyk: CrewManifestUpdate_[20161117'T'060136Z].csv
  10. */
  11.  
  12. //final String PATTERN_MANIFEST_FULL = "CrewManifestFull\\_\\[(2)\\d{3}[0-1]\\d[0-3]\\dT[0-2]\\d{5}[Z]\\]\\.(csv|CSV)";
  13. //final String PATTERN_MANIFEST_UPDATE = "CrewManifestUpdate\\_\\[(2)\\d{3}[0-1]\\d[0-3]\\dT[0-2]\\d{5}[Z]\\]\\.(csv|CSV)";
  14. final String PATTERN_MANIFEST_FULL = "CrewManifestFull\\_\\[(2)\\d{3}[0-1]\\d[0-3]\\dT[0-2]\\d{5}[Z]\\]\\.(csv|CSV)";
  15. final String PATTERN_MANIFEST_UPDATE = "CrewManifestUpdate\\_\\[2\\d{3}[0-1]\\d[0-3]\\d(['’])T\\1[0-2]\\d{5}[Z]\\]\\.(csv|CSV)";
  16. Pattern fullManifestPattern = Pattern.compile(PATTERN_MANIFEST_FULL);
  17. Pattern updateManifestPattern = Pattern.compile(PATTERN_MANIFEST_UPDATE);
  18.  
  19. List<String> testStrings = new ArrayList<>();
  20. /* testStrings.add("CrewManifestFull_[yyyy-MM-dd’T’HH:mm:ssZ].csv");
  21. testStrings.add("CrewManifestUpdate_[yyyy-MM-dd’T’HH:mm:ssZ].csv");
  22. testStrings.add("CrewManifestFull_[20160219'T'130523Z].csv");
  23. testStrings.add("CrewManifestFull_[10-10-2016T042057Z].csv");
  24. testStrings.add("CrewManifestFull_[10-10-2016T04:20:57Z].csv");
  25. testStrings.add("CrewManifestFull_[2016-10-10T04:20:57Z].csv");
  26. testStrings.add("CrewManifestUpdate_[2016-10-10T04:20:57Z].csv");
  27. testStrings.add("CrewManifestFull_[2016-10-10'T'04:20:57Z].csv");
  28. testStrings.add("CrewManifestUpdate_[yyyy-MM-dd’T’HH:mm:ssZ].txt");
  29. testStrings.add("CrewManifestFull_[2016-12-29'T'13:05:23Z].csv");
  30. testStrings.add("CrewManifestUpdate_[2016-12-29'T'13:05:23Z].csv");*/
  31. //testStrings.add("CrewManifestFull_[2016-10-10'T'04:20:58Z].csv");
  32. testStrings.add("CrewManifestUpdate_[20161117'T'060136Z].csv");
  33. testStrings.add("CrewManifestUpdate_[20161117’T’060136Z].csv");
  34. testStrings.add("CrewManifestUpdate_[20161117'T’060136Z].csv");
  35. testStrings.add("CrewManifestUpdate_[20161117T060136Z].csv");
  36.  
  37. //testStrings.add("CrewManifestUpdate_[20161230T140058Z].csv");
  38. //2016-10-13 00:09:30,877 [172.18.0.2] [VA_Scheduler_Worker-7] INFO a.s.l.c.w.p.m.SftpManifestRequest - fileName=./crewmanifests/CrewManifestFull_[20161012T063001Z].csv, lastModified=2016-10-12T07:07:58.000Z, uploadAllowanceTime=5 minutes, oldEnough=true, matchesFull=false, matchesUpdate=false
  39. //CrewManifestFull_[YYYYMMDDThhmmssZ].csv
  40. for (String s: testStrings) {
  41. boolean matchesFull = fullManifestPattern.matcher(s).matches();
  42. boolean matchesUpdate = updateManifestPattern.matcher(s).matches();
  43. System.out.println("String: "+s+"\nmatchesFull: "+matchesFull+"\nmatchesUpdate: "+matchesUpdate);
  44. }
  45.  
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement