Message 1 of 29
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here's a list of filenames:
(setq lst '("1396_000-ERT-LAS-DWG-ST03-00-1001.dwg" "1396_000-ERT-LAS-DWG-ST03-00-1001_recover.dwg"
"1396_000-ERT-IRR-DWG-ST03-00-5002.dwg" "1396_000-ERT-MEP-DWG-ST03-01-8001.dwg"
"1396_000-ERT-MEP-DWG-ST03-01-8112.dwg" "1396_000-ERT-MEP-DWG-ST03-01-8112_xx.dwg"
"SCOPE OF WORK.dwg" "Third floor.dwg"))
Your challenge if you choose to accept it is to come up with the best pattern for filter to be used as argument for _FilterThisMrRobot sub
(Defun _FilterThisMrRobot (wt l)
(vl-remove-if-not
'(lambda (sg)
(vl-some '(lambda (f)
(wcmatch sg f)) wt)
)
l
)
)
Expected pattern would be
'("1396_000-ERT-@@@-DWG-ST03-0#-####.dwg")
(__FilterThisMrRobot '("1396_000-ERT-???-DWG-ST03-0#-####.dwg") LST)
Result:
"1396_000-ERT-LAS-DWG-ST03-00-1001.dwg"
"1396_000-ERT-IRR-DWG-ST03-00-5002.dwg"
"1396_000-ERT-MEP-DWG-ST03-01-8001.dwg"
"1396_000-ERT-MEP-DWG-ST03-01-8112.dwg"
Here's more samples [ Correction ]
(setq lst '("LEW-SD-YEE-SW-LA-LY-20092.dwg" "LEW-SD-YEE-SW-LA-LY-10092.dwg" "XX_LEW-SD-YEE-SW-LA-LY-10092.dwg" "LEW-SD-YEE-SS-AR-LY-20102.dwg" "LEW-SD-YEE-SS-AR-L1-50092.dwg" "LEW-SD-YEE-SS-AR-L1-50092_recover.dwg" "LEW-SD-YEE-SS-AR-LY-01110.dwg" "From Ground Floor.dwg" "LEW-SD-YEE-SS-AR-LY-01100_latest.dwg"))Pattern(s): '("LEW-SD-YEE-@@-@@-L?-#####.dwg")
Pattern(s): '("LEW-SD-YEE-S@-@@-LY-#####.dwg") Results: "LEW-SD-YEE-SW-LA-LY-20092.dwg" "LEW-SD-YEE-SW-LA-LY-10092.dwg" "LEW-SD-YEE-SS-AR-LY-20102.dwg""LEW-SD-YEE-SS-AR-L1-50092.dwg"<-- Should not been here as there's only one of these pattern "LEW-SD-YEE-SS-AR-LY-01110.dwg"
And to make it a bit more challenging, if A pattern appears more than 3 times, then it should be included on the list
(setq lst '("300612-22-A-101.dwg" "300612-22-D-312.dwg" "300612-22-D-313.dwg" "300612-22-D-501.dwg" "300612-22-D-313_updated.dwg" "300612-22-X-01.dwg" "300612-22-X-02.dwg""300612-22-X-10.dwg" "300612-22-X-25.dwg" "D-TEMPLATE.dwg" )) Pattern(s): '("300612-22-@-###.dwg" "300612-22-X-##.dwg") Results:"300612-22-0-101.dwg"<-- Should not been here as there's only one of these pattern
"300612-22-A-101.dwg" <---- changed 0 to A for completeness "300612-22-D-312.dwg" "300612-22-D-313.dwg" "300612-22-D-501.dwg" "300612-22-X-01.dwg" "300612-22-X-02.dwg" "300612-22-X-10.dwg" "300612-22-X-25.dwg"
Hope you guys like it and have a go at it
EDIT: Revised the samples and result to comply with the requirements
Solved! Go to Solution.