Filezilla通过正则表达式 (RegEx) 来过滤文件名

打算弃用WinSCP,开始使用Filezilla来实现简单的通过正则表达式进行文件名过滤。
虽然WinSCP支持命令行,支持自建脚本,但是那些功能对我来说太高级了,我只想通过正则表达式来过滤文件名这一个单一功能即可。


WinSCP的作者表示软件的文件名过滤并不是正则表达式 (RegEx)(点击三角箭头展开)


Untitled


martin
Site Admin
martin avatar
Joined:
Posts:
34,036
Location:
Prague, Czechia

eranm wrote:

I know the * means 0 or more occurrences, would [0-9]+ work in this case?
I already wrote above that * does not do what you think.
WinSCP file mask is not a regular expression.
See https://winscp.net/eng/docs/file_mask
So + won't work either.



FileZilla的网站上找到的关于文件名过滤支持正则表达式 (RegEx) 的描述(点击三角箭头展开)


Untitled


Regular expressions are used in filename filters as a way to filter files on either the client or server side.


The flavor of regular expressions used are POSIX extended regular expressions.


Wildcard

The wildcard . matches any character. For example, a.b matches any string that contains an "a", then any other character and then "b", a.b matches any string that contains an "a", and then the character "b" at some later point.


Given regular expressions R and S, the following operations over them are defined to produce regular expressions:

  • (concatenation) RS denotes the set of strings that can be obtained by concatenating a string in R and a string in S. For example, let R = {"ab", "c"}, and S = {"d", "ef"}. Then, RS = {"abd", "abef", "cd", "cef"}.

Depending on the regex processor there are about fourteen metacharacters, characters that may or may not have their literal character meaning, depending on context, or whether they are "escaped", i.e. preceded by an escape sequence, in this case, the backslash \. Modern and POSIX extended regexes use metacharacters more often than their literal meaning, so to avoid "backslash-osis" or leaning toothpick syndrome it makes sense to have a metacharacter escape to a literal mode; but starting out, it makes more sense to have the four bracketing metacharacters ( ) and { } be primarily literal, and "escape" this usual meaning to become metacharacters. Common standards implement both. The usual metacharacters are {}^$.|+? and \.


Filezilla应用正则表达式 (RegEx)效果图如下:

posted @ 2020-09-11 17:41  柠檬茶多放糖  阅读(842)  评论(0编辑  收藏  举报