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.
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.
Doing a search and replace with regular expressions enable.
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.
… 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: ^.*?(?=:)
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.