且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过正则表达式获取文件路径中的最后一个反斜杠

更新时间:2022-11-14 22:04:23

您是否只想要一切在最后一个反斜杠(文件名)之后?

Do you just want everything after the last backslash (the filename)?

([^ \\] +)$

文件名将包含在捕获中。

The filename will be contained in the capture.

要从最后一个反斜杠开始进行匹配。 。

To match starting at the last backslash you'd do...

\\ [^ \\] + $

我对Coldfusion不熟悉,但是我假设如果它执行正则表达式,那么它也会捕获。如果您确实需要该职位,并且可以从比赛中获得该职位,则第二个表达式可能就是您想要的。

I'm not familiar with coldfusion, but I'm assuming that if it does regular expressions, it does captures as well. If you do really need the position and can get that from the match, the second expression might be what you want.

(为清楚起见并进行评论编辑)

(Edited for clarity and to answer comment)