更新时间:2023-02-21 10:58:33
试试这个:
(.+?)(\.[^.]*$|$)
这将:
.logs
是名为 .logs
的文件,而不是文件扩展名),这在 Unix 中很常见.foo.bar.jpeg
获取foo.bar
.secret-letter
为您提供 secret-letter
..logs
is a file named .logs
, not a file extension), which is common in Unix.foo.bar.jpeg
gets you foo.bar
.secret-letter
gets you secret-letter
.注意:正如评论者 j_random_hacker 所建议的那样,这与宣传的一样,但出于可读性目的,您可能希望在前面加上锚点.
Note: as commenter j_random_hacker suggested, this performs as advertised, but you might want to precede things with an anchor for readability purposes.