Skip to main content

I am trying to use the string search command to extract the file names from a text string, Path attribute. by reverse searching the path string in order to establish the location of the last sub directory i.e. \\

@FindString(@Value(Path),\\,-0,caseSensitive=TRUE)

 

The forward search works but I can't get the reverse (right to left) to work! using a negative startIdx

 

image 

Please also check the FileNamePartExtractor.


A negative start index doesn't mean it searches from right to left, rather that it returns the position of the first match from the end of the string rather than the start.

 


A negative start index doesn't mean it searches from right to left, rather that it returns the position of the first match from the end of the string rather than the start.

 

ok, but Isn't that effectively the same thing if im attempting to establish where the file name starts


ok, but Isn't that effectively the same thing if im attempting to establish where the file name starts

Sorry, poor wording on my part.

 

Example:

Search the word pagan for letter a

imageIf start index is 0 or not set, this would return the a in position 1

If start index is set to -1 the search starts at position 4 and so the result is -1 (a is not found)

If start index is set to -2, the search starts at position 3, a is found and so the result is 3

If start index is set to -4, the search starts at position 1, a is found and sot he result is 1

 

The negative start index just sets the start of the search from the end of the string, the search itself is still left to right


ok, but Isn't that effectively the same thing if im attempting to establish where the file name starts

Thanks for this, will try and find another way


ok, but Isn't that effectively the same thing if im attempting to establish where the file name starts

What are you trying to get? The filename, the last subdirectory or something else?

 

The FilenamePartExtractor will give both the above

_filename - filename with extension

_rootname - filename without extension

_dirname - last subdirectory


ok, but Isn't that effectively the same thing if im attempting to establish where the file name starts

The Path attribute was created from a dir listing exported to csv and not via FME, unfortunately. effectively just a string from which i'm attempting to extract the file name. if that makes sense?


ok, but Isn't that effectively the same thing if im attempting to establish where the file name starts

The FilenamePartExtractor works on an attribute, so that's not an issue at all. Set the attribute containing your string as the Source Filenameimage 


ok, but Isn't that effectively the same thing if im attempting to establish where the file name starts

Thank you, that worked a treat


Reply