Код:
; #FUNCTION# ====================================================================================================
; Name...........:  _PathSplitByRegExp
; Description....:  Splits the path to 5 elements.
; Syntax.........:  _PathSplitByRegExp($sPath)
; Parameters.....:  $sPath - Path to split.
;
; Return values..:  Success - Array that contain 5 elements:
;                                                                           [0] = Original path ($sPath)
;                                                                           [1] = Drive
;                                                                           [2] = Directory
;                                                                           [3] = File name
;                                                                           [4] = Extension
;                   Failure - Returns 0 and sets @error as following:
;                                                                           1 - $sPath is not a valid path (the path is not splitable).
;                                                                           2 - Array is invalid. No matches.
;                                                                           3 - [Should not happen] Bad pattern, array is invalid. @Extended = offset of error in pattern.
; Author.........:  Gibbo, Mod. by G.Sandler a.k.a (Mr)CreatoR.
; Modified.......:
; Remarks .......:  * The path can include backslash as well (exmp: C:/test/test.zip).
;                   * This function does not take a command line string. It works on paths, not paths with arguments.
;                   * This differs from _PathSplit in that the drive letter or servershare retains the "" not the path.
;                   * RegEx Built using examples from "Regular Expressions Cookbook (O’Reilly Media, 2009)"
; Related........:
; Link...........:
; Example........:  Yes.
; ===============================================================================================================
Func _PathSplitByRegExp($sPath)
	If StringStripWS($sPath, 8) = '' Then
    Return SetError(1, 0, 0)
	EndIf

	$sPath = StringReplace($sPath, '/', '\')

	Local $aRet = StringRegExp($sPath, '^(?i)([a-z]:|\\\\(?:\?\\)?[a-z0-9_.$]+\\[a-z0-9_.]+\$?)?(\\(?:[^\\/:*?"<>|\r\n]+\\)*)?([^\\/:*?"<>|\r\n.]*)\.?((?:[^.\\/:*?"<>|\r\n]+)?)$', 2)

	Switch @error
    Case 1
    	Return SetError(2, 0, 0) ;Array is invalid. No matches.
    Case 2
    	Return SetError(3, @extended, 0) ;Bad pattern, array is invalid. @Extended = offset of error in pattern.
	EndSwitch

	Return $aRet
EndFunc   ;==>_PathSplitByRegExp