Skip to main content
PDF Automation Station
Community Expert
Community Expert
December 9, 2023
Answered

Regular Expression

  • December 9, 2023
  • 3 replies
  • 1798 views

How do I write a regular expression to replace everything after the 2nd occurrence of a period?

    This topic has been closed for replies.
    Correct answer try67

    Ah OK. I think a Regular Expression is a bit of an overkill for that.
    You can do it using this code:

     

    var s = "123.456.78910.1234";
    var parts = s.split(".");
    var newS = (parts.length<2) ? parts[0] : parts[0]+"."+parts[1];
    console.println(newS);

    3 replies

    try67
    Community Expert
    Community Expert
    December 9, 2023

    Replace it with what?

    PDF Automation Station
    Community Expert
    Community Expert
    December 10, 2023

    Remove it.  Replace with ""

    try67
    Community Expert
    try67Community ExpertCorrect answer
    Community Expert
    December 10, 2023

    Ah OK. I think a Regular Expression is a bit of an overkill for that.
    You can do it using this code:

     

    var s = "123.456.78910.1234";
    var parts = s.split(".");
    var newS = (parts.length<2) ? parts[0] : parts[0]+"."+parts[1];
    console.println(newS);
    John T Smith
    Community Expert
    Community Expert
    December 9, 2023

    All of your previous messages are in Acrobat About formsdoctor - Adobe Community

     

    Is this another Acrobat message?

    PDF Automation Station
    Community Expert
    Community Expert
    December 9, 2023

    Yes

    kglad
    Community Expert
    Community Expert
    December 9, 2023

    what app? acrobat? animate? something else?

    PDF Automation Station
    Community Expert
    Community Expert
    December 9, 2023

    Acrobat (JavaScript)

    kglad
    Community Expert
    Community Expert
    December 9, 2023

    in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

    p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



    <"moved from using the community">