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


Thread Tools Search this Thread Display Modes
Old January 9th, 2018, 06: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
Old January 10th, 2018, 05:11 PM
step's Avatar
step step is offline
Senior Contributor
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Check for character

You could do this:
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

Reply With Quote
Old April 18th, 2018, 10:14 AM
ThePorge ThePorge is offline
Regular Contributor
Join Date: Aug 2011
Location: Georgia
Posts: 88
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

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 03:18 AM.

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