Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating a GREP style to superscript after a letter

Community Beginner ,
May 20, 2019 May 20, 2019

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

5.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 20, 2019 May 20, 2019

\bm\K2|3

Also covers m3

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 20, 2019 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 20, 2019 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 20, 2019 May 20, 2019

it must work.

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

Like this:

m2.gif

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 21, 2019 May 21, 2019

Hi Winterm (long time no see!)

Your grep says :

"catch 2 if followed by (c)m"

or

"catch 3"

cm2.jpg

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:

m2.jpg

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

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 21, 2019 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 21, 2019 May 21, 2019

I must say I missed your correction too... [busy day too...]

Should work fine too.

Although I have the feeling that custom class characters are more efficient. But I'm quite unsure about that....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 08, 2023 Aug 08, 2023

Hello, I know some time passed but I have a question.
How to modify this GREP to make superscript different set of characters?
I have "loremipsum1)" and want part "1)" to be in superscript.
I was trying with "\b[mck]?m\K[1)]\b but no luck, I'm completly green to GREP.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 08, 2023 Aug 08, 2023
LATEST

try 

\b[ckm]?m\K1\)

For some reasons putting a word boundary after the closing parenthesis does not work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2019 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines