Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Get Integer from a String

Participant ,
Jan 13, 2020 Jan 13, 2020

I am working on a document that creates fields. I am using a counting variable to append unique integers to created fields, e.g. topPh4, newPage4, etc. I want to have a button read its own name, figure out the integer attached to it, then look for fields with the same number. I know I could use

right(button, XX)

only the number will often (but not initially) be 2 digits. Is there a method to get the number, however many digits, from the name? I can imagine using some if statements to check the end for integers, and when found, concatenate them, but its seems brutish. Any better ideas?

TOPICS
Create PDFs , How to , PDF forms
880
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jan 13, 2020 Jan 13, 2020

What you posted looks nothing like Acrobat JavaScript. Is that what you're referring to?

If so, you can use this: event.target.name.match(/\d+$/)[0]

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2020 Jan 13, 2020

What you posted looks nothing like Acrobat JavaScript. Is that what you're referring to?

If so, you can use this: event.target.name.match(/\d+$/)[0]

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 13, 2020 Jan 13, 2020

I shouldn't have used the code tags since it wasn't real code. I was referring to the "right" method for strings... But I then came across regular expressions and knew I was getting close. Thanks for the help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2020 Jan 13, 2020

There's no "right" method in JavaScript. You must be thinking of VBA or something like that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 13, 2020 Jan 13, 2020

Mm the string function right? Is that more accurate?

String Functions 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2020 Jan 13, 2020

This is not the documentation of Acrobat JavaScript. It's for ColdFusion's CFML.

"function" and "method" are synonyms, for the most part.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 13, 2020 Jan 13, 2020
LATEST

Well.... that's embarrassing...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines