Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.util.regex.Pattern;
- public class Main {
- public static void main(String[] args) {
- /**
- * CrewManifestUpdate\_\[2\d{3}[0-1]\d[0-3]\d(['’])T\1[0-2]\d{5}[Z]\]\.(csv|CSV)
- [11:17:03] Piotr Rybarczyk: CrewManifestUpdate_[20161117'T'060136Z].csv
- */
- //final String PATTERN_MANIFEST_FULL = "CrewManifestFull\\_\\[(2)\\d{3}[0-1]\\d[0-3]\\dT[0-2]\\d{5}[Z]\\]\\.(csv|CSV)";
- //final String PATTERN_MANIFEST_UPDATE = "CrewManifestUpdate\\_\\[(2)\\d{3}[0-1]\\d[0-3]\\dT[0-2]\\d{5}[Z]\\]\\.(csv|CSV)";
- final String PATTERN_MANIFEST_FULL = "CrewManifestFull\\_\\[(2)\\d{3}[0-1]\\d[0-3]\\dT[0-2]\\d{5}[Z]\\]\\.(csv|CSV)";
- final String PATTERN_MANIFEST_UPDATE = "CrewManifestUpdate\\_\\[2\\d{3}[0-1]\\d[0-3]\\d(['’])T\\1[0-2]\\d{5}[Z]\\]\\.(csv|CSV)";
- Pattern fullManifestPattern = Pattern.compile(PATTERN_MANIFEST_FULL);
- Pattern updateManifestPattern = Pattern.compile(PATTERN_MANIFEST_UPDATE);
- List<String> testStrings = new ArrayList<>();
- /* testStrings.add("CrewManifestFull_[yyyy-MM-dd’T’HH:mm:ssZ].csv");
- testStrings.add("CrewManifestUpdate_[yyyy-MM-dd’T’HH:mm:ssZ].csv");
- testStrings.add("CrewManifestFull_[20160219'T'130523Z].csv");
- testStrings.add("CrewManifestFull_[10-10-2016T042057Z].csv");
- testStrings.add("CrewManifestFull_[10-10-2016T04:20:57Z].csv");
- testStrings.add("CrewManifestFull_[2016-10-10T04:20:57Z].csv");
- testStrings.add("CrewManifestUpdate_[2016-10-10T04:20:57Z].csv");
- testStrings.add("CrewManifestFull_[2016-10-10'T'04:20:57Z].csv");
- testStrings.add("CrewManifestUpdate_[yyyy-MM-dd’T’HH:mm:ssZ].txt");
- testStrings.add("CrewManifestFull_[2016-12-29'T'13:05:23Z].csv");
- testStrings.add("CrewManifestUpdate_[2016-12-29'T'13:05:23Z].csv");*/
- //testStrings.add("CrewManifestFull_[2016-10-10'T'04:20:58Z].csv");
- testStrings.add("CrewManifestUpdate_[20161117'T'060136Z].csv");
- testStrings.add("CrewManifestUpdate_[20161117’T’060136Z].csv");
- testStrings.add("CrewManifestUpdate_[20161117'T’060136Z].csv");
- testStrings.add("CrewManifestUpdate_[20161117T060136Z].csv");
- //testStrings.add("CrewManifestUpdate_[20161230T140058Z].csv");
- //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
- //CrewManifestFull_[YYYYMMDDThhmmssZ].csv
- for (String s: testStrings) {
- boolean matchesFull = fullManifestPattern.matcher(s).matches();
- boolean matchesUpdate = updateManifestPattern.matcher(s).matches();
- System.out.println("String: "+s+"\nmatchesFull: "+matchesFull+"\nmatchesUpdate: "+matchesUpdate);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement