Jump to content

Variable length field trimming last five characters


Recommended Posts

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 by dreimer
Link to comment
Share on other sites

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 by step
Misread the OP and thought he only wanted the last 5 digits.
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...