dreimer Posted September 13, 2013 Share Posted September 13, 2013 (edited) I'm sure there is an easy rule, but I can't seem to figure it out. Looking to trim the last five characters of a variable length field so using left won't work in the rule since I don't know how many characters there are in each instance of data. So I want to return everything except the last five characters. TIA. I should mention the last five are numbers and everything before that is alpha. Edited September 13, 2013 by dreimer Quote Link to comment Share on other sites More sharing options...
step Posted September 13, 2013 Share Posted September 13, 2013 (edited) Several ways to do this. Using the Left function and changing the trim based on the length of the text minus the last 5 characters: var text = Field("Code"); return Left(text,text.length-5); or with regex removing all the digits: var text = Field("Code"); return text.replace(/\d/g,""); or with substring var text = Field("Code"); return text.substring(0,text.length-5); Edited September 13, 2013 by step Misread the OP and thought he only wanted the last 5 digits. Quote Link to comment Share on other sites More sharing options...
dreimer Posted September 13, 2013 Author Share Posted September 13, 2013 Seems like those rules are returning the last five characters. I want the last five trimmed from the field and give me everything but the last five characters. Quote Link to comment Share on other sites More sharing options...
dreimer Posted September 13, 2013 Author Share Posted September 13, 2013 The removing all the digits one will work I think. Thank you. Just wondering if there is a way to do it if all characters were alpha. Quote Link to comment Share on other sites More sharing options...
step Posted September 13, 2013 Share Posted September 13, 2013 Don, I edited my post after I re-read your post and realized I misread it the first time. Any of those three options should work for you now. The easiest solution, though, is the first one that uses the Left function. Quote Link to comment Share on other sites More sharing options...
dreimer Posted September 13, 2013 Author Share Posted September 13, 2013 Perfect, thank you very much. I will hold onto these for future use! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.