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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 9th, 2018, 05:37 PM
gdellaiera gdellaiera is offline
Regular Contributor
 
Join Date: Nov 2016
Posts: 78
Default Check for character

Does anyone know the best way to check for a character?

I'm looking for an apostrophe ( ' ) at the beginning of a variable (years attended) that are being input by csv. In single record they get typed in '12-'15 but when uploaded in batch, excel will sometimes remove the initial apostrophe (due to it being a command in the software).

I'd like the rule to check for the apostrophe and return the variable if there is one and return ' + variable if there isn't.

I am thinking that this would have to be an OnRecordStart rule, but other than that I am a little lost.

Thanks for any and all help!
Reply With Quote
  #2  
Old January 10th, 2018, 04:11 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Check for character

You could do this:
Code:
return Field("Years Attended").replace(/'(\d{2})/g, "'$1")
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old April 18th, 2018, 09:14 AM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 59
Default Re: Check for character

I would think your grep would be /'?(\d{2})/g
What you have won't find the first two digit string if the leading apostrophe is not there.
Reply With Quote
Reply

Tags
fusionpro, javascript

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:20 PM.


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