Skip to main content

Dear All,

 

Here is my issue with the FindString() function :

 

I have the following string stored in user parameter value_to_test = "101,102" ; the attribute "ProgNum" contains values that range from 100-900 and I want to set a new attribute "FoundNum" to be = "true" when "ProgNum" is one the (comma-separated) values of value_to_test.

 

As FindString(string,strToFind) should return the index in string that matches strToFind , I've tried the following expression :

@FindString($(value_to_test),@Value(ProgNum))

I have also tried the FindStringRegularExpression

@FindRegularExpression($(value_to_test),@Value(ProgNum))

None of the them is working ! Quite despaired I've also tried to revert $(value_to_test) and @Value(ProgNum) in the function call, but it does not work better...

 

Does anyone have an explanation what it is not working and what I am doing wrong ??

 

Thanks in advance

 

NB : I know that I could work with AttributeSplitter etc. but I would like to know why the FindString and FindRegularExpression functions are not working here

Try inserting a ParameterFetcher to get $(value_to_test) into an attribute and use that in FindString() rather than the parameter reference.


The problem is that value_to_test contains comma's. When you replace these with spaces, @FindString works as expected.

If you want to work with comma's in value_to_test, you can use a Conditional Value in the AttributeManager.

Conditional_Value_3Alternatively, you can use a StringSearcher.


The problem is that value_to_test contains comma's. When you replace these with spaces, @FindString works as expected.

If you want to work with comma's in value_to_test, you can use a Conditional Value in the AttributeManager.

Conditional_Value_3Alternatively, you can use a StringSearcher.

Good catch @geomancer​ , I didn't see that at first. It's then possible to enclose the reference with double quotes, e.g.

@FindString("$(value_to_test)","@Value(ProgNum)")

Unless value_to_test or ProgNum contains double quotes, of course...


The problem is that value_to_test contains comma's. When you replace these with spaces, @FindString works as expected.

If you want to work with comma's in value_to_test, you can use a Conditional Value in the AttributeManager.

Conditional_Value_3Alternatively, you can use a StringSearcher.

thanks a lot @geomancer and @david_r !

Definitely, I'll never get used to FME's weird under-the-hood behavior and its implicit and unexpected feature type handling/conversion... 


Reply