Skip to main content
Solved

How can keep only the last character from a string.

  • October 16, 2013
  • 2 replies
  • 414 views

Hi,

 

 

I'm trying to create an attribute that is simply the final character of another attribute. Using the substring extractor I can remove the final character with and stand and end on 0 and -2, and I can extract a character at a known location with 18, 19. The length of string hoewever vary so I need to find a way of dealing wit the last character rather than the xth. Is there another combination of start and end index that will allow me to do this or do I need another transformer?

 

 

Thanks

Best answer by kim

Negative values are calculated from the end of the string. Perhaps use a start of -1 and end of -1?
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, 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.

2 replies

Forum|alt.badge.img+5
  • Best Answer
  • October 16, 2013
Negative values are calculated from the end of the string. Perhaps use a start of -1 and end of -1?

Forum|alt.badge.img
  • October 17, 2013
You can as well extract this last character using a StringSearcher with a Regular Expression: (.){1}$.

 

 

The dot means any character (except new lines)

 

The number in curly brackets indicates the number of characters you want to get

 

the dollar sign means the end of the string

 

 

In our case the expression would match the any 1 character before the end of the string (i.e.: the end of the string)

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