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

GREP Bold first word if expression

Explorer ,
Jan 29, 2021 Jan 29, 2021

I want to do a GREP to bold the first word of every paragraph IF the first word has a colon after it. 

 

Basically i dont want it to bold if there is no colon after the first word (if i could build it to only apply to the first two words even better)

 

Can this be done?

TOPICS
How to , Type
5.0K
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
Explorer ,
Jan 29, 2021 Jan 29, 2021

I tired this and i think it works

^\S+:

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 ,
Jan 29, 2021 Jan 29, 2021

If you will only have one colon per paragraph, you could use GREP Style in the paragraph settings.

.*(?=:)

image.png

The code could be modified to stop at the first colon if necessary.

David Creamer: Community Expert (ACI and ACE 1995-2023)
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 ,
Jan 29, 2021 Jan 29, 2021

I would prefer nested styles for that (Performance!).

 

But as GREP in paragraph style - try the following.

I don't know what exactly you want. Here are a few slightly different examples.

 

  • (multiple) word(s) with formatting the colon

 

^[^:]+?:

 

 

  • (multiple) word(s) without formatting the colon

 

^[^:]+?(?=:)

 

 

  • one word (only letters) + colon

 

^[\l\u]+?:

 

 

  • two words (only letters) + colon

 

^[\l\u]+?(\h[\l\u]+?)?:

 

 

 

If that works for you

have fun

😉

 

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
Explorer ,
Feb 01, 2021 Feb 01, 2021

Awesome thanks, I have used paragraph styles and it worked mostly, however a few issues if not every paragraph has a colon it bolds the text till it finds one. i just wanted to add it to my main paragraph style so all text remains as is unless there is a colon after the firswt word then it wouold bold the first word. Thanks!

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 ,
Feb 16, 2021 Feb 16, 2021

… and it worked mostly, however a few issues if not every paragraph has a colon it bolds the text till it finds one …


By @Nathan Rule

 

That shouldn't happen.

Can you show a screenshot and the grep style please?

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 ,
Feb 16, 2021 Feb 16, 2021

“... That happens all the time!”  😉

 

(^/)  The Jedi

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 ,
Feb 17, 2021 Feb 17, 2021

Imho [… but it's just a personal comment!],

 

^[^:]+?:

 

doesn't seem to me a Grep syntax particularly relevant (":" double exlusion)!

 

^[^:]+:

 

or

 

^.+?:

 

(^/)

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 ,
Feb 16, 2021 Feb 16, 2021

Don't do a GREP; do a nested style.

Mike Witherell
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 ,
Feb 17, 2021 Feb 17, 2021

Unless I'm missing something (entirely possible), I don't think nested styles would work for paragraphs without colons. 

image.png

Nested style coding:

image.png

Grep coding (^.*?(:) 

image.png

 
David Creamer: Community Expert (ACI and ACE 1995-2023)
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
Explorer ,
Feb 17, 2021 Feb 17, 2021

Couldnt have done it better myslef. Exactly why i wanted a grep style.

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 ,
Feb 17, 2021 Feb 17, 2021
LATEST

Remember the question:

I want to do a GREP to bold the first word of every paragraph IF the first word has a colon after it

 

Basically i dont want it to bold if there is no colon after the first word (if i could build it to only apply to the first two words even better)

 

Can this be done?


By @Nathan Rule

 

@Nathan Rule 

please give some concrete examples or better: a sample file for testing.


Otherwise everything is just a shot in the dark.

 

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