Skip to main content
Participant
May 12, 2024
Answered

GREP for a letter followed by a digit

  • May 12, 2024
  • 1 reply
  • 573 views

I'd like to search for the letter T followed by a digit (T1, T2, T3) and then change only the digit to a subscript.

I can search for T(\d) but how to I get it to change the formatting of only the digit?

This topic has been closed for replies.
Correct answer brian_p_dts

Use Positive Lookbehind: (?<=T)\d

1 reply

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
May 12, 2024

Use Positive Lookbehind: (?<=T)\d

Inspiring
May 13, 2024

Perfect! You can also use the new shortcut for positive lookbehind:

T\K\d

I personally prefer this shortcut because it is quick to type. Sadly there are no similar shortcuts for lookahead or for negative lookbehind/lookahead.

Community Expert
May 14, 2024

@Tim Sheasby I am not sure that \K is a new shortcut. I have been using it now for some versions of InDesign. For the unversed what it does is reset the match counter so it mimics the behaviour of positive lookbehind

-Manan

-Manan