我有一个结构如下的网址:<domain>/<subdirectory>/<filename>-<semantic_version>-<hash>.<filetype>
例如,它可能看起来像:https://cdn.example.com/sample_files/some_file-1.2.3-56857cfc709d3996f057252c16ec4656f5292802.css
到目前为止,我有以下正则表达式为我提供了完整的文件名。但是,我想分别获得上面定义的filename
,semantic_version
和hash
。您可以假设filename
名称中不会包含破折号。
([^/\\&\?]+)$(?<=(?:.js))
使用多个不匹配-
字符的捕获组。
([^-/\\&\?]+)-([^-/\\&\?]+)-([^-/\\&\?]+)\.[a-z]+$(?<=(?:.js))