Fabian Posted April 24, 2010 Share Posted April 24, 2010 hello, i have a field named Title in my template. in this field there will be different job titles flowing in, but as an example lets use the bottom title: DBA / CDC: Marketing Manager what i need is a rule that will remove anything before the ":" but then also remove the ":" and space after it. i should end up with just: Marketing Manager the common denominator in all job titles that flow into the template is the ":" character and space afterward. Quote Link to comment Share on other sites More sharing options...
esmith Posted April 27, 2010 Share Posted April 27, 2010 I didn't actually test this, but I believe it's correct: var title = Field("Title"); // determine position of colon in string var colonLoc = title.indexOf(":"); // remove chars to left of colon plus colon itself title = Right(title, title.length-colonLoc-1); // remove any leading or trailing spaces title = Trim(title); return title; Quote Link to comment Share on other sites More sharing options...
Fabian Posted April 27, 2010 Author Share Posted April 27, 2010 thanks for your reply! ill give it a shot. Quote Link to comment Share on other sites More sharing options...
Doug Pershing Posted May 3, 2010 Share Posted May 3, 2010 In this case a split would work nicely. The CustType would be equal to everything to the left of the colon character and CustType2 would be equal to everything on the right of the colon. Using the .split would be similar to using TextToColumns in Excel. Whatever character you enter inside the quotes becomes your delimiter. Since it is zero based the 1st value is [0], the second value is [1], and so on... CustTypeSplit=Field("Version").split(":") CustType=CustTypeSplit[0] CustType2=CustTypeSplit[1] Quote Link to comment Share on other sites More sharing options...
rrdwitt Posted January 22, 2019 Share Posted January 22, 2019 Hi all, could anyone tell me the code to remove a character to the right of a field? Lets say the "name" field contains someones name but there is an asterisk directly next to it. Can I keep the name and remove the asterisk? thanks Quote Link to comment Share on other sites More sharing options...
David Miller Posted January 23, 2019 Share Posted January 23, 2019 Hi all, could anyone tell me the code to remove a character to the right of a field? Lets say the "name" field contains someones name but there is an asterisk directly next to it. Can I keep the name and remove the asterisk? thanks You can try this: var corName = Field("Name"); // Replace with your field name. corName = corName.replace(/\*$/, ''); // If there is more than one asterisk, this removes the last asterisk only. return Trim(corName); // Trims all leading and trailing white space and returns your field with the last asterisk removed. 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.