Replace comma at end of line with period (Find&Replace

My document has things ilke:

1 Some, words.* Some more words,
2 Some words,* Some more words.

How can I

A. Find all commas at the end of the lines and replace them with periods (not editing commas elsewhere)?
B. Find all commas before an asterisk* and replace them with periods?

Commas at end of paragraphs

Provided your comma is at end of a paragraph, i.e. not followed by a linebreak created with Shift+Enter, use the following regular expression:

,$ = comma (your target) and dollar which is a descriptor for end-of-paragraph

The replace string is only a full stop.

Commas followed by a linebreak

In this case the regular expression is ,\n = comma and \n which is a descriptor for a linebreak

Commas before an asterisk

The regular expression is ,\* where the asterisk is escaped with a reverse solidus otherwise it means repeat 0 or more times the previous character. Your replace string is .* = full stop and asterisk. If you don’t want to keep the asterisk, just omit it in the replace string.

1 Like