Skip to main content
Participant
January 17, 2019
Answered

Part of a field

  • January 17, 2019
  • 2 replies
  • 571 views

What I am trying to do is use part of a field that is filled in by a user to fill in another field.  The two examples I am looking at working with are social security numbers and dates.

I have one field that the user inputs the full social security number into.  On other pages, I only need the last four digits of the number.  Is there a way that this can be done?

My second one is a date that is inputted by the user in a YYYYMMDD format.  Some of the pages need each digit added to a single charter block and some of them need a date that takes up two lines, year on top and month date below.  Is there a way either of those can be done?

My experience with Java is very limited so I would prefer to be pointed in the direction so I can learn the info over just being given the answer if possible.

This topic has been closed for replies.
Correct answer Thom Parker

What you need is a regular expression. Regular expressions are a very popular tool for parsing strings.

Here's an article on the topic:

https://acrobatusers.com/tutorials/text-matching-regular-expressions

But, the string parsing you've mentioned are pretty simple. You could also use simpler sting manipulation operations.

Here's on article on that topic:

https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings

2 replies

try67
Community Expert
Community Expert
January 18, 2019

It's also very important to know that what you're using is called JavaScript, not Java. Similar names, but very different languages.

Participant
January 18, 2019

try67  wrote

It's also very important to know that what you're using is called JavaScript, not Java. Similar names, but very different languages.

  Thanks for that, that will teach me not to proof read before I hit submit

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 18, 2019

What you need is a regular expression. Regular expressions are a very popular tool for parsing strings.

Here's an article on the topic:

https://acrobatusers.com/tutorials/text-matching-regular-expressions

But, the string parsing you've mentioned are pretty simple. You could also use simpler sting manipulation operations.

Here's on article on that topic:

https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often