模式匹配
描述#
如果某些文件应与(或从) 其他设备同步,配置相应的 SyncFilePattern/IgnorereFilePattern。 所有模式都相对于文件夹根目录(你在进入 DevMode 时选择的文件夹)。
Caution
The priority of the IgnoreFilePattern is higher than SyncFilePattern, so if your pattern both covered the same file, the file will be ignored.
匹配模式语法#
常规文件名匹配本身,即:模式
foo匹配文件foo,subdir/foo以及名为foo的目录。 空格被当作普通字符处理,但前导和尾随空格除外,后者自动 trimmed。星号 (
*) 匹配文件名中的零或更多字符,但与目录分隔符不匹配。te*ne匹配telephone,subdir/telephone但不是tele/phone。双星号 (
**) 和上面相同,但匹配目录分隔符。te**ne匹配telephone,subdir/telephone和tele/sub/dir/phone。问号 (
?) 匹配非目录分隔符的单个字符。te??st匹配tebest但不匹配teb/st或test。方括号 (
[…]) 表示字符范围:[a-z]匹配任何小写字符。粗括号 (
{}) 表示一组逗号分隔的替代品:{banana,pineapple}匹配banana或pinepele。反斜杠 (
\) “逃避”一个特殊的字符,使它失去了它的特殊含义。 例如,\{banana\}匹配{banana}并且不表示上面的一组例子。 Windows不支持转义字符。以
/或./开头的模式只匹配文件夹的根目录中。/fooor./foo匹配foo但不匹配subdir/foo.以
(?i)前缀开头的模式允许大小写不敏感的模式匹配。(?i)test匹配test,TEST和tEsT。(?i)前缀可以与其他模式合并,例如图案(?i)picture*.png表示Picture1.PNG应同步。 在 Mac OS 和 Windows 中,模式匹配总是不区分大小写。
Note
Prefixes can be specified in any order (e.g. “(?i){foo,bar}/*/bar”), but cannot be in a single pair of parentheses (not "{foo,(?i),bar}/*/bar").
示例#
Given a directory layout:
and with following config:
The priority of the IgnoreFilePattern is higher than SyncFilePattern and the end result becomes: