1

I recover from a FTP server, flat files which has these names:

  • abc
  • abc.flag
  • abc.tmp
  • test
  • test.flag
  • test.tmp

In my case, I have to recover just the files: abc and test. I tried with the following mask but it did not work: "(.+\.tmp)| (. + \.flag) " is there another way to do this ?

Mahmoud
  • 325
  • 10
  • 25

1 Answers1

2

Can't find of an expression that would select all but .tmp and .flag files, but here's an example to select them, which uses .+(?:flag|tmp)$.

Updated

Assuming negative lookaheads are allowed, see this example that only selects non .tmp and .flag files, which uses

^.+\.(?!flag|tmp).+$|^\w+$

swlim
  • 452
  • 4
  • 17
  • No, I want to exclude just the files that have the extension .tmp and .flag – Mahmoud Jul 03 '16 at 13:42
  • Updated my answer, presuming you can match those with .flag and .tmp and exclude them yourself. Have you also considered [getting the file extension](http://stackoverflow.com/questions/3571223/how-do-i-get-the-file-extension-of-a-file-in-java) and filtering those that you dont want? – swlim Jul 03 '16 at 13:53
  • No, saw that in TalendOS there is a tFTPListe that I give just the masck of files I want to recover, this masck is in regex – Mahmoud Jul 03 '16 at 14:04
  • This mask is working fine now `"[abc]"+"+([^.flag]|[^.tmp])"` I get file abc that don't have extension .flag or .tmp – Mahmoud Jul 03 '16 at 14:11
  • Updated my answer again, this time with an expression that selects the file you want. Looking at the one you commented, `[^.flag]`, means you dont want any files that has a `.`, `f`, `a` or `g`. In other words, if the file extension is `.glaf`, it wouldnt be selected as well. Same situation goes to `[^.tmp]`. Are you sure that is what you need? – swlim Jul 03 '16 at 14:17
  • You are right, I changed my mask to `"abc"+"+(?!flag|tmp)"` Because I want to get juste file **abc** not **abc.flag**, **def** or **def.flag** for that I fixed the value abc – Mahmoud Jul 03 '16 at 14:33