第一种方法:
$path="C:\201401\88\下载的文件\Haren-25-1247-1255-2010.pdf"
$sfile_name="12345.pdf"
$aArray = StringRegExp($path, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1)
$renamepath=$aArray[1]&$aArray[2]&$sfile_name
MsgBox(0,"",$renamepath)
第二种方法:
$path="C:\201401\88\下载的文件\Haren-25-1247-1255-2010.pdf"
$sfile_name="12345.pdf"
$renamepath=StringRegExpReplace($path, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$","$2$3")&$sfile_name
MsgBox(0,"",$renamepath)
|