Build regex that separates file names in a string

时间:2018-08-22 13:46:30

标签: regex

Given a string of file names like this: 'New Text Document (2).txt New Text Document (3).txt New Text Document (4).txt New Text Document.txt\n' I would like to create a list with the following elements: ['New Text Document (2).txt', 'New Text Document (3).txt', 'New Text Document (4).txt', 'New Text Document.txt'] It seems that using regexes are the answer. Any ideas?

1 个答案:

答案 0 :(得分:1)

I think this is the expression you are looking for:

\ ?(.+?\.\w+)

Of course you need to use that in your language of choice to get the captured matches

相关问题