www.webdeveloper.com
Results 1 to 2 of 2

Thread: Code to Extract a Letter from a String

  1. #1
    Join Date
    Feb 2013
    Posts
    1

    Code to Extract a Letter from a String

    Hi all,

    This isn't a question related to the web, but it's Javascript so I am hoping someone might be able to assist. I am trying to create a dynamic stamp in Adobe which requires me to write Javascript for a textbox control. The stamp has two text boxes that I need to fill from one string. The string is in the format of
    "08363-G-5109-DWG-R-00001_A.pdf" with a varying number of characters before the underscore, but always the same after the underscore. In the first text box I need
    08363-G-5109-DWG-R-00001 which I get with
    Code:
    event.value = event.source.source.documentFileName.slice(0,-6);
    this works great. The second box needs to contain the letter after the underscore, in this case 'A' The code that I have found that relates to getting this value doesn't seem to work. I am a VBA programmer I suspect that the logic is dfferent in Javascript.

    Code:
    var str = event.source.source.documentfilename;
    var strt = str.lastindexof("_");
    var end = str.lastindexof(".");
    event.value = str.substring(strt,end);
    Any assistance would be greatly appreciated!
    Bent

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,266
    See codingForums.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles