匹配以 900 x 500 开头的文件名
我有一个来自我们使用的 CMS 之一的媒体选择器,我想限制用户选择的图像。对于横幅,图像应以名称 900 x 500 开头。我在想是否可以使用正则表达式来执行此操作。
我尝试检查文件名是否以 900 开头,但它不起作用
/^900/
I have this media picker from one of the CMS that we use and I want to restrict the image selected by the user. For the banners, the image should start with the name 900 x 500. I'm thinking if its possible regex to do this.
I try this to check if the filename starts with 900 but it doesn't work
/^900/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为下面的正则表达式可以解决这个问题:
它将测试名称是否以 900x500 或 900X500 开头,然后接受任何其他字符。 (至少一个)。
I think the following regex will do the trick:
It will test that the name starts with 900x500, or 900X500, accepting afterwards any other characters. (At least one).
这可能不是您想要的,但仍然是一个适合您需求的解决方案。
替代方法是更改字段的数据类型。您可以安装一些非常好的软件包,它们使您能够选择用户选择和上传的图像的大小(尺寸)。
您可以在此处观看演示http://www.youtube.com/watch?v=cVVD60NHMRk
或者您可以在此处查看包 http://our.umbraco.org/ items/backoffice-extensions/image-cropper
干杯。
凯杰
This may not be what you are after but is a solution none the less which may suit your needs.
an alternative to this would be to change the datatype of the field. There are some really good packages you could install which enable you to choose the size(dimensions) of the images a user picks and uploads.
you can view a demo here http://www.youtube.com/watch?v=cVVD60NHMRk
or you can view the package here http://our.umbraco.org/projects/backoffice-extensions/image-cropper
cheers.
KJ