I have a table that contains a field with street names. Each street name ends with the street type. Fore example, Washington St, Happy Valley Rd, Redstone Dr. I need to extract the last part of the street name and have it populate a field called Street Type. I been trying to use the AttributeSplitter transformer but it only splits strings according to a delimiter (in this case it's a space), but this does not work. Any suggestion on using a different transformer or combination of transformers? Solutions need to be in FME as this task is part of a greater workflow.
Try the Regular Expressions.
It has been some time since I've used FME, but I know a while back they had a Regular Expressions Transformer (or the AttributeSplitter had a Regular Expressions option).
You should be able to use a regular expression to match some form of pattern.
For example, the address:
123 abc st, Sesame Street
could be matched by the regular expression:
Which indicates the pattern as,
- from the start of the string ($)
- there will be a sequence of digits : [0-9]+
- followed by a white space character (space, tab, etc) : \w
- followed by a string consisting of Upper and Lower case alpha characters: [a-zA-Z]+
- followed by the string of interest in the pattern: ([st|dr|av]) *NOTE
- followed by any number of white space and alpha characters: [\wa-zA-Z]+
NOTE The parenthesis () tag that part of the pattern to an attribute that you can use later on in your FME script.
I hope this gives you some pointers. I'll follow this question to help further if required.
SubstringExtractor should work too
Extracts a substring from the source attribute. The substring is taken from the range of characters specified. Character indexes start at 0 for the first character. A negative index is used to indicate the position relative to the end of the string (-1 is the last character, -2 the second last, and so on). The index can also be taken from the value of another attribute.
If the last index is greater than or equal to the length of the string then it is treated as if it were the end of the string. If the first index is greater than the last index then an empty string is placed into the result attribute.
Each of the index parameters may either be entered as a number, or can be taken from the value of a feature attribute by selecting the attribute name from the pull-down list.
To trim off the first character only, use a start of 1 and an end of -1 To trim off the last character only, use a start of 0 and an end of -2 To extract the second and third characters in the string, use a start of 1 and an end of 2