Skip to main content
Participating Frequently
December 5, 2018
Answered

Adding commas in a column of numbers in FrameMaker with a regular expression

  • December 5, 2018
  • 2 replies
  • 882 views

Does anyone have a regular expression for how to add a comma to a column(s) of numbers in FrameMaker? The columns are 4, 5, and 6 digits mixed.

    This topic has been closed for replies.
    Correct answer Barb Binder

    Hi ArtistCrystal:

    For 4-6 digit strings:

    Find: (\d+)(?=(\d\d\d)+\b)

    Change to: $1,

    ~Barb

    2 replies

    Barb Binder
    Community Expert
    Community Expert
    December 6, 2018

    Right? I love regular expressions! They dramatically cut down on the time it takes to clean up files.

    In addition to the resource that Stefan linked to, I also recommend checking out this book from regular forum contributor Peter Kahrel: Shop: InDesignSecrets. Yes, it is geared towards an InDesign user—and FrameMaker does not yet support GREP styles—but REGEX is REGEX and the information in this guide is invaluable. And the focus is on writing expressions that are specifically used to clean up documents for publishing.

    And since Stefan is on this thread, I’m going to take a moment to remind him that I think it is really important that we add the ability to save our REGEX in a menu with descriptive names so that we can access them easily the next time we need them. FrameMaker does remember the last 10 expressions (10 for Find and 10 for Change) but when you perform additional find and change activities, they drop off the bottom of the list. I guess the bright side is that I’m getting much more efficient at writing the expressions that I need because I have to keep re-keying them in.  

    ~Barb

    ~Barb at Rocky Mountain Training
    Participating Frequently
    December 11, 2018

    good morning Barb,

    Thank you for the REGEX and for the book suggestion. I have ordered the book and downloaded the PDF - just haven't had time to look at it yet I also have the information from the blog post recommended by Stefan. Have a great week.

    Crystal

    Barb Binder
    Community Expert
    Barb BinderCommunity ExpertCorrect answer
    Community Expert
    December 5, 2018

    Hi ArtistCrystal:

    For 4-6 digit strings:

    Find: (\d+)(?=(\d\d\d)+\b)

    Change to: $1,

    ~Barb

    ~Barb at Rocky Mountain Training
    Participating Frequently
    December 5, 2018

    Whew hooo, thank you Barb! I just added 825 commas in about two seconds! Now I'm excited to learn more about regular expressions. Thanks again.

    Legend
    December 6, 2018

    You might also want to have a look at this blog post on the Adobe TechComm blog about regular expressions. It gives a good start, I think.