Skip to main content
Inspiring
August 5, 2024
Answered

Acrobat split field into other fields between repeating delimiters

  • August 5, 2024
  • 2 replies
  • 991 views

I would like to split up this text into seven fields. There are always seven sections. However the delimeters for each section vary. Don't know if this is too complicated to accomplish with a custom validation script. Thank you in advance!!!:

 

SECTION1/TEXT HERE SPACES VARY UP UNTIL LAST SPACE SECTION2/TEXT HERE SPACES VARY UP UNTIL LAST SPACE SECTION3/TEXT HERE UP UNTIL END OF LINE NO SPACE

SECTION4/TEXT HERE SPACES VARY UP UNTIL LAST SPACE SECTION5/TEXT HERE UP UNTIL END OF LINE NO SPACE

SECTION6/TEXT HERE SPACES VARY UPUNTIL LAST SPACESECTION7/TEXT HERE UP UNTIL END OF LINE NO SPACE AND NO FURTHER TEXT

 

Alternative explanation...delimeter pattern (extract each change in color to different field - can be text1, text2, text3, text4, text5, text6, text7):

"/" until last " " of text "/" until last " " of text  "/" until end of line no space

"/" until last " " of text "/" until end of line no space

"/" until last " " of text "/" until end of line no space

    This topic has been closed for replies.
    Correct answer try67

    Thank you for the idea. Could I bother you for the script to remove the last four characters of a string, and am a correct in assuming that the script will be placed in the source field "run custom validation script" window, and that the field referenced in the script will be the field receiving the result? Much appreciated.


    To remove the last four characters of a string you can use the substring method, like this:

    var a = "abcdefghijk";

    a = a.substring(0, a.length-4);

    // a is now "abcdefg"

     

    As for the location of the code, that depends on what should trigger it. Is this a value that is entered by the user, imported, calculated? Something else?

    2 replies

    try67
    Community Expert
    Community Expert
    August 5, 2024

    Do you mean you want to extract just the last word before each "/"? If so, split first by "/", then split each one of those strings by " ". Then take the last element in the arrays of the second split commands.

    dpoagAuthor
    Inspiring
    August 5, 2024

    Thank you for your question. Essentially I need to extract each iteration of text in between "/" and the last " " before repeating (the text can contain muliple words with spaces). The number of spaces after "/" vary. The sections that I need text extracted  in between "/" and end of line are because the field is formated like a paragraph with 2 carriage returns and of course the end (it is copied and pasted into the field that way for convenience. Also, I'm assuming the end of the line would have some sort of invisible return character, that I'm not sure of. The three line "paragraph" is copied as OCR text and pasted into the field from another PDF). Perhaps there's another way to accomplish this if a validation script may not do the trick?

     

    Another way to look at it:

    /text_to_last_space   /text_to_last_space   /text_to_carriage_return

    /text_to_last_space  /text_to_carriage_return

    /text_to_last_space   /text_to_end

     

    Much appreciated. 

    try67
    Community Expert
    Community Expert
    August 6, 2024

    Split by "/", then trim the excess spaces at the end of each string.

    Peru Bob
    Community Expert
    Community Expert
    August 5, 2024

    I've moved this from the Using the Community forum (which is the forum for issues using the forums) to the Acrobat forum so that proper help can be offered.


    Scroll down here to see a list of the forums:
    https://community.adobe.com/

    dpoagAuthor
    Inspiring
    August 5, 2024

    Thank you.