I want to search and replace each occurrence of a certain pattern with a decimal number which begins at `1` and increments by one for each match. I can find similarly worded questions that turn out not to be about incrementing a counter but modifying each match by a fixed amount. Other similar questions are about inserting line numbers rather than an incrementing counter. Example, before: #1 #1.25 #1.5 #2 After: #1 #2 #3 #4 My real data has a lot more text all around the stuff I want to re-number.