问题描述
我有以下文件名称:
当x是一个数字时(x可以是介于0到100之间的数字)
I have the following names of files:When x is a number (x could be number between 0 to 100)
fileX
fileXblabla
fileX.X
fileX.Xblabla
例如
For example
fileX --> file1
fileXblabla --> file1blabla
fileX.X --> file5.3
fileX.Xblabla --> file2.9blabla
我的问题是如何匹配目录下的每种文件ls和正则表达式或其他)
my question is how to match each one of the following kind of files under directory (by ls and Regular Expressions or something else)
例如
For example
fileX
在目录下,我们想要获得所有文件,如:file1或file2或file3 ... ..file100
Under directory we want to get all files like: file1 or file2 or file3 …..file100
fileXblabla
在目录下,我们希望得到所有文件,如:file1bla或file2bla或file3bla ... ..file100bla
Under directory we want to get all files like: file1bla or file2bla or file3bla …..file100bla
fileX.X
在目录下,我们希望获得像file1.1或file2.1或file3.1 ...这样的所有文件。 .file100.100
Under directory we want to get all files like: file1.1 or file2.1 or file3.1 …..file100.100
fileX.Xblabla
在目录下,我们希望获得所有文件,例如:file1.1bla或file2.1bla或file3.1bla ... ..file100.100bla
Under directory we want to get all files like: file1.1bla or file2.1bla or file3.1bla …..file100.100bla
推荐答案
试试这个:
Try this:
^file(100|[1-9]\d|\d)(\.(100|[1-9]\d|\d))?(bla)*$
这篇关于正则表达式以特殊格式匹配文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!