InclusiveExclusion Posted January 16, 2021 Share Posted January 16, 2021 I'm trying to write a regular expression to test if a file path has a file extension at the end. I'm testing for... after the last fullstop (period) then there's only characters up to the end of the string. I get a bit fullstop happy writing regex and worry that im casting too wide a net. This works i think but is there a better way? Local $path = '"' & @ScriptDir & "\Log_" & @YEAR & "-" & @MON & "-" & @MDAY & ".csv" & '"' $array = StringRegExp($path,"\.(.+)\z",0) msgbox(1,"HAS FILE EXTENSION?",$array) I know about PathSplit. Just trying to learn. Link to comment Share on other sites More sharing options...
Nine Posted January 16, 2021 Share Posted January 16, 2021 You are grabbing the ending quotes. Not sure you really want that. This way will work with or without ending quotes : $array = StringRegExp($path,'\.([^"]+)',1) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
rudi Posted January 21, 2021 Share Posted January 21, 2021 Hi. There is a builtin function to deal with drive/path/filename/extension See _PathSplit() Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now