Skip to main content

I have a test looking for many possible cases. one of the cases I want to find is Any folder inside of any folder that has some specific names. (BTW I am using directory and File Pathname reader to create a list) and then a tester to get all of the special cases.)

I have a test line like path_directory_windows CONTAINS *\project_data\working\**\*

I don’t get any errors with this syntax but it does not find the folders.

 

Basically i am only wanting to find folders within any project_data\working folder that contain any files.

If it doesn’t contain a file I am not concerned with it.

Any help with a correct regex statement that would work, or the proper syntax for the contains statement are what i am needing.

I have tried this regex unssuccessfully

project_data\/working\/k^\/]+\/\^\/]+

TIA

 

Hi @gisbradokla 

 

You could try using the StringSearcher with the regex set up like:

.*\\project_data\\working\\g^\\]+\.+^\\]+ 

 

 

You could also try using the AI Assist to get closer to what you are looking for. 

 

This article talks about AI Assist for regular expressions - Regular Expressions and FME

 

I hope this helps!

Crystal


Thank you @crystalatsafe I did use the ai with regex generator. However my result did not match every instance. looking at your result I see that mine needs the escape slash and some other changes. I’ll try it out. 


Also this is the opposite of what i want. 

I am essentially creating a reverse test. anything that passes the test will be my failed.

So for the pass I want any folder that is in the *\project_data\working\” that has a file in it.

\project_data\working\myfile.txt would NOT pass.but,

\project_data\working\anyfoldername\myfile.txt would pass


Hi @gisbradokla 

Is it this what your looking for:

.*\\project_data\\working(\\\^\\]+)+\\\^\\]+\..^\\]+
 

Matches: \project_data\working\abc\def\ghi\j\myfile.txt

Not matched: \project_data\working\myfile.txt & \project_data\working\myfile


This is what i currently have but it is opposite of what i need.

^[^\n]*\\project_data\\working\\[^\\]+\.[^\\]*

You are very close with .*\\project_data\\working(\\\^\\]+)+\\\^\\]+\..^\\]+

I don’t want any file in the *\project_data\working\

But i do want any folder in the *\project_data\working\ folder and i do want any folder that has a file in it in the *\project_data\working\ subfolders

x

 


Hi @gisbradokla ,

Can you only show the first line in the test string? I found there is an issue with providing multiple test lines. But that should not occur when reading data via path reader.

So can you try that regex on your test data to see if it produces the correct output?


I will try that. i wondered about that since it rolls to the next line whether it matches or not.


This is good. 

 

that still doesn’t seem to match any folder. but i guess there is not much overhead. since most of the folders have files. it would just add a folder if it didn’t have a file but again i guess “so what”. since at this point i am looking for files.

 

In the end i think you have what i need. it will find any folder with any file in that specific structure. THANKS @tva 


Reply