Showing results for 
Search instead for 
Do you mean 

How to find the last word in a string using Functional Attributes expression?

by Technical Evangelist ‎02-26-2016 01:45 PM - edited ‎10-24-2017 03:46 PM (552 Views)

Question

How to find the last word in an attribute text string using a Functional Attributes expression?

Answer

To return only the last word in a text attribute string a Functional Attribute expression like the following can be used. The attribute in this example has the name RIVER_NAME, so substitute RIVER _NAME with the appropriate attribute name for your data set.

 

RIGHT(Input.RIVER_NAME, LEN(Input.RIVER_NAME)-SEARCH('@', REPLACE(Input.RIVER_NAME, ' ', '@', 1, LEN(Input.RIVER_NAME)-LEN(REPLACE(Input.RIVER_NAME, ' ', '')))))

 

Note that this example assumes that the special character used in the expression (i.e. '@') does not actually exist in the attribute value. If the @ character is present in the attribute value, then the @ symbol in the example expression will also need to be substituted with a different character (which does not exist in your attribute value.)

Contributors