如何在ColdFusion中按最后一个分隔符拆分String

Abh*_*jan 4 coldfusion coldfusion-9 cfml

在CF9中,我有一个字符串 C:\Docs\472837\nyspflsys\Medical Report\XLSX_46.xlsx

我想最后一个反斜杠来分割它,所以它看起来应该
array[1] = C:\Docs\472837\nyspflsys\Medical Report
array[2] = XLSX_46.xlsx

如何在ColdFusion 9中完成?

Ale*_*lex 6

您可能需要考虑使用GetDirectoryFromPathGetFileFromPath.

<cfset fullPath = "C:\Docs\472837\nyspflsys\Medical Report\XLSX_46.xlsx">

<cfset dirPath  = getDirectoryFromPath(fullPath)>    <!--- C:\Docs\472837\nyspflsys\Medical Report\ --->
<cfset dirPath  = reReplace(dirPath, "[\\/]$", "")>  <!--- C:\Docs\472837\nyspflsys\Medical Report  --->
<cfset fileName = getFileFromPath(fullPath)>         <!--- XLSX_46.xlsx                             --->
Run Code Online (Sandbox Code Playgroud)