Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 23rd, 2010, 06:45 PM
Fabian Fabian is offline
Junior Community Member
 
Join Date: Oct 2008
Posts: 14
Question how to remove text?

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.
Reply With Quote
  #2  
Old April 27th, 2010, 05:16 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 870
Default Re: how to remove text?

I didn't actually test this, but I believe it's correct:
Code:
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;
__________________
Eric Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
  #3  
Old April 27th, 2010, 03:45 PM
Fabian Fabian is offline
Junior Community Member
 
Join Date: Oct 2008
Posts: 14
Default Re: how to remove text?

thanks for your reply! ill give it a shot.
Reply With Quote
  #4  
Old May 3rd, 2010, 07:46 AM
Doug Pershing's Avatar
Doug Pershing Doug Pershing is offline
Junior Community Member
 
Join Date: Aug 2008
Location: Phoenix, AZ
Posts: 37
Default Re: how to remove text?

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]
Reply With Quote
  #5  
Old January 22nd, 2019, 11:35 AM
rrdwitt rrdwitt is offline
Regular Contributor
 
Join Date: May 2016
Location: Missouri
Posts: 53
Default Re: how to remove text?

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
Reply With Quote
  #6  
Old January 23rd, 2019, 09:07 AM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: how to remove text?

Quote:
Originally Posted by rrdwitt View Post
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:
Code:
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.
__________________
David Miller
FusionPro VDP Creator 10.0.26
Adobe Acrobat Pro 2019.008.20074
Suitcase Fusion 20.0.0 (7653)
macOS High Sierra 10.13.6
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:12 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.