How to make everything before the colon bold (Find & Replace)?

I have content like:

some words: some more words
some: some more words

I would like to Find everything before the colon and make it bold.

[Tutorial] “In-line” or “run-in” headings

Doing a search and replace with regular expressions enable.


Once the text it’s selected, you can apply the bold to it or better create a character style with bold character, and apply to them, so for future modifications you only need to modify the style.

1 Like

Is the search still greedy? Can there be more colons in a paragraph? Should the colon not be boldfaced? If so, you should use the pattern ^[^:]*, which includes all characters that aren’t colons, until the first colon. If you want to include the colon, use ^[^:]*:.
Click Find all, then close the dialog box and now don’t click in the text area but either directly apply bold to the selection or apply a character style.

3 Likes

… or until the end of the paragraph, if there’s no colon.

One can use non-greedy operators and look-ahead assertions.

To include colons: ^.*?:
To exclude colons: ^.*?(?=:)

3 Likes

That’s a powerful set of regex operators indeed, but I wonder how many people who are new to regex will be able to make sense of them, let alone use them without wreaking havoc. This is really a tool for experts.