【发布时间】:2023-07-19 03:23:01
【问题描述】:
我正在从 html 迁移到 Drupal。使用迁移模块。
在我们的自定义迁移脚本中,我需要匹配除 images 文件夹之外的所有文件夹中的所有 .html 文件。
将此正则表达式传递给$list_files = new MigrateListFiles([],[],$regex)
下面是html文件的格式
/magazines/sample.html
/test/index.html
/test/format_ss1.html
/test/folder/newstyle_1.html
/images/two.html
我只需要获取前 2 个 html 文件,即,我们排除了以 '_[0-9]' 和 '_ss[0-9]' 结尾的文件以及 images 文件夹中的 .hmtl 文件。
我已经成功排除了 3 和 4,但我无法排除 images 文件夹中的 .html 文件。
$regex = '/[a-zA-Z0-9\-][^_ss\d][^_\d]+\.html/'; //this will do for 3 and 4 files
但我需要排除图像文件夹..
我试过了
$regex = '/[^images\/][a-zA-Z0-9\-][^_ss\d][^_\d]+\.html/'; // not working
它在 PHP 脚本中的工作位置
$regex = '~^(?!/images/)[a-zA-Z0-9/-]+(?!_ss\d|\d)\.html$~' //works in php script
有人可以帮我解决这个问题吗..
【问题讨论】:
-
我想它会在我有时间玩更多之前得到回答。如果没有,我会在空闲时间(还有 5 小时)尝试回答。我不想给出未经检验的想法。与此同时,I made a test case on PHP Live Regex.
-
如果你有时间请看这个..drupal.org/node/2029713#comment-8214739