Skip to main content
Solved

tester with wildcard for "only" any folder following


gisbradokla
Enthusiast
Forum|alt.badge.img+17

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\/[^\/]+\/[^\/]+

TIA

 

Best answer by tva

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

View original
Did this help you find an answer to your question?

8 replies

crystalatsafe
Safer
Forum|alt.badge.img+19

Hi @gisbradokla 

 

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

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

 

 

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


gisbradokla
Enthusiast
Forum|alt.badge.img+17
  • Author
  • Enthusiast
  • April 30, 2024

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. 


gisbradokla
Enthusiast
Forum|alt.badge.img+17
  • Author
  • Enthusiast
  • May 3, 2024

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


tva
Contributor
Forum|alt.badge.img+12
  • Contributor
  • Best Answer
  • May 3, 2024

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


gisbradokla
Enthusiast
Forum|alt.badge.img+17
  • Author
  • Enthusiast
  • May 3, 2024

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

 


tva
Contributor
Forum|alt.badge.img+12
  • Contributor
  • May 3, 2024

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?


gisbradokla
Enthusiast
Forum|alt.badge.img+17
  • Author
  • Enthusiast
  • May 3, 2024

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


gisbradokla
Enthusiast
Forum|alt.badge.img+17
  • Author
  • Enthusiast
  • May 3, 2024

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 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings