Skip to main content
Participating Frequently
May 20, 2019
Question

Creating a GREP style to superscript after a letter

  • May 20, 2019
  • 3 replies
  • 5299 views

Hi,

I'd like to create a GREP style to change the number 2 to a superscript after the letter m

50 m2, balkon 24 m2

Thanks

Mark

    This topic has been closed for replies.

    3 replies

    Braniac
    May 21, 2019

    Hi Mark,

    in case you are on InDesign CC 2019 version 14.0.2 make sure that the following bug fix is installed:

    GREP search fails to find all the matching instances in long InDesign documents

    This fix will not delivered through the Adobe Creative Cloud Desktop App.

    Regards,
    Uwe

    winterm
    Braniac
    May 20, 2019

    it must work.

    What ID version you're using? Could you show Grep Style tab of your para style?

    Like this:

    vinny38
    Braniac
    May 21, 2019

    Hi Winterm (long time no see!)

    Your grep says :

    "catch 2 if followed by (c)m"

    or

    "catch 3"

    Make a character class [23] instead:

    \bc?m\K[23]

    To go further, you could add a word boundary at the end in order to secure a little bit more. Unlikely to get such cases (I had hard time finding an example...), but well, it's just a metacharacter to add:

    And maybe think about square kilometers, or millimeters, why not ^^

    \b[mck]?m\K[23]\b

    winterm
    Braniac
    May 21, 2019

    hi vinny

    thank you, sure you're right.

    it's been a damn busy days, obviously, too busy… I should take a break.

    winterm
    Braniac
    May 20, 2019

    \bm\K2|3

    Also covers m3

    \bc?m\K2|3 will pick up centimeters, too.

    Mark SK-MAuthor
    Participating Frequently
    May 20, 2019

    Thank you for your prompt reply.

    I've tried the GREP style as suggested however it changes all the 2's and not just the 2 after m.

    Ultra Geniş Dış Kabin

    23 m2

    winterm
    Braniac
    May 20, 2019

    … or try this safer approach with parenthesis:

    \bc?m\K(2|3)

    or, if you don't care about cubic and centimeters, just the basic:

    \bm\K2