Skip to main content
Question

REGEX support


checcosisani
Contributor
Forum|alt.badge.img+12

Hi

 

can you help me to find the correct regex to extract only the string in bold (ALESSANO)

 

\\\\199.168.30.208\\dati\\pippo\\PUGLIA\\ALESSANO\\INGRESSO\\ALESSANO\\tracciato unico.shp

 

thx

 

Francesco

4 replies

birgit
Influencer
Forum|alt.badge.img+16
  • Influencer
  • October 19, 2023

You can use stackoverflow for this. Also do you just want ALESSANO or du you always want the value between the second to last \\ and the last \\.

Also can't you just use the FilenamePartExtractor transformer for this kind of stuff.


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • October 19, 2023

If you want the directory the shapefile resides in, I would consider using the FilenamePartExtractor. Passing that string will result in a _dirname attribute.

image


david_r
Celebrity
  • October 19, 2023

I would skip using a regex for this, simply for the reason that it gets a bit unmaintainable unless you're already familiar with it. The FilenamePartExtractor is my preferred solution.

For fun, you could also simply use an AttributeSplitter followed by a ListIndexer. This has the added bonus of giving direct access to all the individual folder names:

image


takashi
Influencer
  • October 22, 2023

Hi @checcosisani​ , I agree that FilenamePartExtractor is a better solution in this case, but if you would like to know a regular expression to extract the interest part anyway, try this regex with StringSearcher.

(?<=\\)[^\\]+(?=\\[^\\]+$)

 


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