用于检测图像的格式化名称的正则表达式

问题描述 投票:-1回答:1

我需要检测尺寸结束的图像(NUMxNUM)或一些静态字,如(图标,小,普通,大)

已加星标的项目是正确的规则:

/test/abcd/files/01_aa_100x200.jpg *
/test/abcd/files/abcd_221x105.jpg *
/test/abcd/files/01_aa_icon.jpg *
/test/abcd/files/01aa_iconblabla.jpg
/test/abcd/files/aa_small.jpg *
/test/abcd/files/aa0_test.jpg

我用它但不能正常工作

\/([0-9a-z-]{1,})\/([0-9a-f]{2})([0-9a-f]{2})\/(.+)\_[x0-9|small|icon|normal|large](.+)\.(jpg|png|gif|jpeg)

Demo

regex apache .htaccess detection
1个回答
0
投票

请尝试以下方法:

\/([0-9a-z-]+)\/([0-9a-f]{2})([0-9a-f]{2})\/(.+)\_(\d+x\d+|small|icon|normal|large)\.(jpg|png|gif|jpeg)

Demo

© www.soinside.com 2019 - 2024. All rights reserved.