php glob模式匹配任意位数的数字 [英] php glob pattern match for arbitray number of digits

查看:114
本文介绍了php glob模式匹配任意位数的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以用php glob函数匹配任意数量的数字?我正在尝试匹配图像缩略图的文件名,这些缩略图的尺寸范围从2到4位数不等.

Is it possible to match an arbitrary number of digits with the php glob function? I'm trying to match file names for image thumbnails that end with dimensions ranging from two to four digits.

我知道我可以提供一个数字范围,但这只能匹配一个字符:

I know I can supply a digit range, but this only matches a single character:

glob("thumbname-[0-9]-[0-9].jpg")

这将匹配thumbname-1-1.jpg,但不匹配thumbname-10-10.jpg,等等.

This will match thumbname-1-1.jpg but not thumbname-10-10.jpg, etc.

推荐答案

尝试使用:glob("thumbname-[0-9]*-[0-9]*.jpg")

我做了一个测试,对我有用.

I made a test and it works for me.

这篇关于php glob模式匹配任意位数的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆