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

I desperately need a GREP search for applying styles between tags

New Here ,
Jan 22, 2024 Jan 22, 2024

Copy link to clipboard

Copied

Hi, I have searched very hard for a while and not found an answer. I'm not good with any form of coding and am finding this very difficult so am grateful for any help.

 

I have documents with a lot of text that I import from Word; scattered throughout the text are boxed sidebars, in the following format: <box><box Header>ExampleTitle</box Header>ExampleText</box>

 

I need a way to search for these sidebars and at the very least apply a paragraph style to everything within <box></box>, but even better if possible, I need to also apply a different paragraph style to everything within <box Header></box Header> ...and the cherry on top would be to delete all these tags at the same time, although I could of course just search and delete the tags seperately afterwards.

 

I found a GREP at one point that would apply the style across the whole document, between the first <box> it found and the last </box> it found - not ideal. Obviously I need this to work in seperate bits scattered throughout the document.

 

TOPICS
How to , Scripting

Views

150

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Jan 22, 2024 Jan 22, 2024

Hi @Shaira, I will try to give you a quick answer, but you may find you need a more detailed answer. Here is what I would try first:

 

1. Use find/change to make sure that <box> starts a line, and </box> ends a line (so put carriage returns before and after if necessary.

 

2. Now do same as that for <box Header> — it must start and end on its own line.

Your paragraphs should look like this:

Screenshot 2024-01-22 at 21.33.09.png

3. Now do Find Grep: 

<box>\r([\s\S]*?)</box>

Change To:

$1

Change paragraph style to:

[select your "Box"

...

Votes

Translate

Translate
Community Expert ,
Jan 22, 2024 Jan 22, 2024

Copy link to clipboard

Copied

Hi @Shaira, I will try to give you a quick answer, but you may find you need a more detailed answer. Here is what I would try first:

 

1. Use find/change to make sure that <box> starts a line, and </box> ends a line (so put carriage returns before and after if necessary.

 

2. Now do same as that for <box Header> — it must start and end on its own line.

Your paragraphs should look like this:

Screenshot 2024-01-22 at 21.33.09.png

3. Now do Find Grep: 

<box>\r([\s\S]*?)</box>

Change To:

$1

Change paragraph style to:

[select your "Box" paragraph style].

Screenshot 2024-01-22 at 21.44.39.png

4. Then another find grep:

<box Header>([\s\S]*?)</box Header>$

 

Change To:

 

$1

 

Change paragraph style to:

[select your "Box Header" paragraph style].

 

See if that is any use. It may need more refinements.

- Mark

Votes

Translate

Translate

Report

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
New Here ,
Jan 22, 2024 Jan 22, 2024

Copy link to clipboard

Copied

You have absolutely nailed it, thank you!!!!!!!!!!!!!!!!

Votes

Translate

Translate

Report

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 ,
Jan 22, 2024 Jan 22, 2024

Copy link to clipboard

Copied

LATEST

Great! 👍 

Votes

Translate

Translate

Report

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