Skip to main content
Best Answer

Why won't Substring drop last character of attribute?

  • March 23, 2018
  • 5 replies
  • 130 views

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 :-)

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

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
  • Author
  • March 23, 2018

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+26
  • 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.