Solved

Strings with numbers

  • 27 January 2016
  • 5 replies
  • 12 views

Badge +7

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

icon

Best answer by erik_jan 27 January 2016, 16:00

View original

5 replies

Userlevel 2
Badge +12

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.

Badge +10

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...

Badge +10

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!

Badge +7

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.

Badge +10

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

stripofflastchar.fmw

Reply