Skip to main content
Solved

Why won't Substring drop last character of attribute?


Forum|alt.badge.img

I have a Condition Statement within AttributeManager that checks if an attribute has a letter at the end of the value.

If this is true then I use Substring to drop the last character.

However, when I use the above it always returns the original value (ex. 999a returns 999a instead of 999).

It does not seem to work with any negative number at the end but if I change -2 to a positive number like 3 it works and returns 999.

Any thoughts on what I am doing wrong here?

Regards

Best answer by david_r

You can also do the whole thing in an AttributeCreator:

@ReplaceRegEx(@Value(HOUSENUM),"[a-zA-Z]$","")

0684Q00000ArL1sQAF.png

FME is fun :-)

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

5 replies

david_r
Celebrity
  • March 23, 2018

You can try the following expression:

@Left(@Value(HOUSENUM),@StringLength(@Value(HOUSENUM))-1)

david_r
Celebrity
  • March 23, 2018

Or using the SubstringExtractor transformer:


david_r
Celebrity
  • Best Answer
  • March 23, 2018

You can also do the whole thing in an AttributeCreator:

@ReplaceRegEx(@Value(HOUSENUM),"[a-zA-Z]$","")

0684Q00000ArL1sQAF.png

FME is fun :-)


Forum|alt.badge.img
david_r wrote:

You can try the following expression:

@Left(@Value(HOUSENUM),@StringLength(@Value(HOUSENUM))-1)
The last one worked like a charm...your the man david_r.

 

 

Cheers

 


erik_jan
Contributor
Forum|alt.badge.img+18
  • Contributor
  • March 23, 2018

The Substring function takes a start position and a length as arguments.

The SubstringExtractor takes a start position and end position as arguments.

I know, confusing. Would be nice if they would take the same arguments.


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