Skip to main content
EALS
Inspiring
January 27, 2023
Answered

GREP question: how to format text between tags < >

  • January 27, 2023
  • 1 reply
  • 1189 views

Hello people,

 

Does anyone know how can I format the text between "<" and "> using GREP? 

 

CIDADE DE SÃO PAULO. Sistema Integrado de Gestão do Relacionamento com o Cidadão - Manual do Usuário - Módulo Atendimento. São Paulo: Prefeitura de São Paulo, 2020b. Disponível em: <http://wiki.govit.prefeitura.sp.gov.br/images/8/8f/Apostila_M%C3%B3dulo_Atendimento._revFinal_2020.pdf>. Acesso em: 16 de jan. de 2023.

 

In my example above, I want to finde the red text (between "<>") and format it.

 

Thks

This topic has been closed for replies.
Correct answer Peter Spier

I select all text inside the same story. I attached a sample file...


OK, I see the problem. There is an error in Mike's original GREP expression, and I carried it through in my suggested changes.

Remove the \ before the < and > in the look-behind and the look-ahead and it should work.

1 reply

Mike Witherell
Community Expert
Community Expert
January 27, 2023

(?<=<).+(?=>)

change to is blank but you would apply formatting of a character style for the red)

Mike Witherell
Peter Spier
Community Expert
Community Expert
January 27, 2023

Mike's expression would format more text than intended if there is more than one set of <> in the paragraph.

I would use either (?<=\<).+?(?=\>) or (?<=\<)[^>]+(?=\>), presuming there ar no cases of nested text.

EALS
EALSAuthor
Inspiring
January 30, 2023

Hello Peter,

 

Also thanks for your time. I'm still getting all text replaced. Please, check it out:

 

I must be doing something wrong, right?