Skip to main content
Solved

Strings with numbers

  • January 27, 2016
  • 5 replies
  • 99 views

pushpa
Contributor
Forum|alt.badge.img+9

I have a Shapefile with 9000 records and one of the attribute columns contain strings (numbers and letters). Column width is set to 4 characters

I need to find all records with last character is a "letter" and delete that letter.

ie:

ST4W

S4W

Above records I would like to delete "W" from the records

Could someone help me to do this using FME?

thanks

Best answer by erik_jan

You can use the StringReplacer, use the regular expression [a-zA-Z]$ to remove the last character if it is in the mentioned range and replace with nothing. Or use [a-z]$ and case sensitive No.

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

erik_jan
Contributor
Forum|alt.badge.img+23
  • Contributor
  • Best Answer
  • January 27, 2016

You can use the StringReplacer, use the regular expression [a-zA-Z]$ to remove the last character if it is in the mentioned range and replace with nothing. Or use [a-z]$ and case sensitive No.


davideagle
Contributor
Forum|alt.badge.img+22
  • Contributor
  • January 27, 2016

SubStringExtractor to extract the 4th character to new attribute.

AttributeClassifier to test that attribute to see if its Alphabetic.

Records that pass go through another SubStringExtractor and extract values 0 to 2 or 0 to -2 from the original attribute to a new attribute or overwrite the old one.

Or do some Regex magic...no doubt about to appear below this post...


davideagle
Contributor
Forum|alt.badge.img+22
  • Contributor
  • January 27, 2016

SubStringExtractor to extract the 4th character to new attribute.

AttributeClassifier to test that attribute to see if its Alphabetic.

Records that pass go through another SubStringExtractor and extract values 0 to 2 or 0 to -2 from the original attribute to a new attribute or overwrite the old one.

Or do some Regex magic...no doubt about to appear below this post...

or above this post... I was too slow!


pushpa
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • January 27, 2016

You can use the StringReplacer, use the regular expression [a-zA-Z]$ to remove the last character if it is in the mentioned range and replace with nothing. Or use [a-z]$ and case sensitive No.

Thanks. not sure what I am doing wrong,

I didn't get the results I expected.


davideagle
Contributor
Forum|alt.badge.img+22
  • Contributor
  • January 27, 2016

Here you go if you want to try it with a couple of standard Transformers.

stripofflastchar.fmw