Question

Regular Expression for parsing multiple filenames from text

  • 15 December 2017
  • 2 replies
  • 17 views

With FME 2015 Desktop, I use the StringSearcher do parse an attribute containing the below text:

-rw-rw----    1 20712    110          1102 Dec 15 09:08 VPDZ22.201712150908.zip
-rw-rw----    1 20712    110          1103 Dec 15 09:18 VPDZ22.201712150918.zip
-rw-rw----    1 20712    110          1102 Dec 15 09:29 VPDZ22.201712150929.zip
-rw-rw----    1 20712    110          1145 Dec 15 09:38 VPDZ22.201712150938.zip
-rw-rw----    1 20712    110          1238 Dec 15 09:48 VPDZ22.201712150948.zip

Hereby I want to obtain a list with all names of the zip-files within this text.

Therefore I try Regular Expressions such as e.g.

(VPDZ22.[0-9]{12}.zip|asc)+

I expect to obtain a list with 5 objects containing the 5 different zip-filenames. However, I always obtain a list containing only one single object, which is the first of the wanted zip-filenames:

VPDZ22.201712150908.zip

How am I to design the Regular Expression for this to work correctly?


2 replies

Userlevel 1
Badge +10

Edit: i just noticed that you are using 2015, i'm not sure whether this functionality was available at that time

If there are multiple matches they get stored in a list. You will need to specify the list name under the Advanced parameters. You will then need to explode or otherwise manipulate the list to see the values

Userlevel 2
Badge +17

To add to @egomm's suggestion, I think the regex itself should be modified too. 

(VPDZ22.[0-9]{12}.zip|asc)+

The regex above matches one or more consecutive "VPDZ22<any character><12 number characters><any character>zip" or "asc".
It matches "VPDZ22.201712150908.zip". However, it matches e.g. "VPDZ22X201712150908Xzip" or "ascasc" too, and does NOT match "VPDZ22.201712150908.asc".

If you intend to find string part(s) that match "VPDZ22.<12 number characters>.<'zip' or 'asc'>", this regex would be better.

VPDZ22\.[0-9]{12}\.(zip|asc)

Reply