Because findregex returns the position at which it finds the text, not the text itself
Because findregex returns the position at which it finds the text, not the text itself
I assume you're using that in the left panel of the dialog?
Hi @jelle, the failure reason has been clarified by @Mark2AtSafe.
I think the StringReplacer transformer is a general way to replace a string or substring(s) that matches a regex with a specific string (to replace [A-C] with "1" in this case). If you want to learn an FME String function that is equivalent to the transformer, try the @ReplaceRegEx function. For example:
@FindRegEx(@Value(SampleSizeCode),[A-C])
works like
[regexp {[A-C]} @Value(SampleSizeCode)]
and stores the startindex of the first hit in a string. (if you add the -all swithc it will store index of the last hit)
To actually acquire the (multi)target of your regexp.
For a single object you can simpy use a stringsearcher with the [A-C] character class. (though if you have many classes i would use a conditionalattributecreator or a attributerangemapper, see last line of this post)
Use a tcl in for instance a attribute creator:
[regexp -all -inline {yourregexp}]
The -inline switch causes the enigine to put the matches in a string.
With
[regexp -all -indices {yourregexp}] you can get the indices(in the string) of the matches.
Together with stringlength you can grab the target objects.
There are a couple of examples on this forum (i think i posted some 2013-2014 somewherish)
Anyway to map characterranges to number i would turn the characters to ascii codes and then rangemap them... no need for regexp there.
I assume you're using that in the left panel of the dialog?
yes, the left side of the panel of the AttributeValueMapper. Would there be any way to say
if @FindRegEx(@Value(SampleSizeCode),RA-C]) = 0
(index starts at 0)
That would be very close to the Conditional Value in the AttributeCreator, which I find less clear for people that have never seen the Workspace. But it works fine.
yes, the left side of the panel of the AttributeValueMapper. Would there be any way to say
if @FindRegEx(@Value(SampleSizeCode),eA-C]) = 0
(index starts at 0)
That would be very close to the Conditional Value in the AttributeCreator, which I find less clear for people that have never seen the Workspace. But it works fine.
You can do conditions in the arithmetic editor with the ?: operator. So something like:
@FindRegEx(@Value(SampleSizeCode),tA-C]) ? 1 : 0
Would mean if you find a value it returns 1, else return 0. I'm still struggling to see it work on the left side of a mapping. Maybe it would work better on the right hand side? Or just put it into an AttributeCreator instead of the AttributeValueMapper. So it's conditional but not using the conditional functionality.
We are thinking about a transformer like TestFilterMapper - with the test conditions of the TestFilter but the mapping of the AttributeValueMapper. It's not got a high priority because the conditional functionality fills that gap. But it sounds like you think it would be a good transformer to have.
You can do conditions in the arithmetic editor with the ?: operator. So something like:
@FindRegEx(@Value(SampleSizeCode),[A-C]) ? 1 : 0
Would mean if you find a value it returns 1, else return 0. I'm still struggling to see it work on the left side of a mapping. Maybe it would work better on the right hand side? Or just put it into an AttributeCreator instead of the AttributeValueMapper. So it's conditional but not using the conditional functionality.
We are thinking about a transformer like TestFilterMapper - with the test conditions of the TestFilter but the mapping of the AttributeValueMapper. It's not got a high priority because the conditional functionality fills that gap. But it sounds like you think it would be a good transformer to have.
I'm in favour the TestFilterMapper. In my opinion, it would be easier to maintain in the Workspace.
For the time being, the Conditional Values also do the job.