正则表达式代码如何过滤所有仅包含数字并以.jpg和/或_number.jpg结尾的名称? [英] Regex code how to filter all names that contain only numbers and end with .jpg and/or _number.jpg?

查看:71
本文介绍了正则表达式代码如何过滤所有仅包含数字并以.jpg和/或_number.jpg结尾的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何过滤所有由数字组成并以.jpg和/或_number.jpg结尾的名称?

背景信息:在SSIS 2008中,我有一个foreach循环,它将文件名存储到所有jpg文件的变量中.文件的枚举器配置当前为: *.jpg 这将处理所有jpg文件.

什么是代码,所以它只能处理喜欢的名字?:

  3417761506233.jpg3417761506233_1.jpg5414233177487.jpg5414233177487_1.jpg5414233177487_14.jpg 

但不是类似

的名称

  abc.jpgabc123.jpgdef.png456.png 

顺便说一句,数字代表EAN代码.我想到了这段代码:

\ d | _ | .jpg

但是SSIS返回一个错误,指出即使文件(名称)在文件夹中,也没有符合条件的文件.

解决方案

您可以在循环中使用脚本任务来进行正则表达式过滤:

How to filter all names that consist of numbers and end with .jpg and/or _number.jpg?

Background info: In SSIS 2008 I have a foreach loop that will store the filename into a variable for all jpg files. The enumorator configuration for Files is currently: *.jpg This will handle all jpg files.

What is the code so it will only handle names likes?:

3417761506233.jpg
3417761506233_1.jpg
5414233177487.jpg
5414233177487_1.jpg
5414233177487_14.jpg

but not names like:

abc.jpg
abc123.jpg
def.png
456.png

The numbers represent EAN codes by the way. I thought about this code:

\d|_|.jpg

but SSIS returns an error stating there are no files that meet the criteria eventhough the files(names) are in the folder.

解决方案

You could use a Script Task within the loop to do the regex filtering: http://microsoft-ssis.blogspot.com/2012/04/regex-filter-for-foreach-loop.html

Or you could use a (free) Third Party Enumerator: http://microsoft-ssis.blogspot.com/2012/04/custom-ssis-component-foreach-file.html

这篇关于正则表达式代码如何过滤所有仅包含数字并以.jpg和/或_number.jpg结尾的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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